MCPcopy Create free account
hub / github.com/geekcomputers/Python / checkInput

Function checkInput

diceV2_dynamic.py:27–39  ·  view source on GitHub ↗
(sides)

Source from the content-addressed store, hash-verified

25# Checks to make sure that the input is actually an integer.
26# This implementation can be improved greatly of course.
27def checkInput(sides):
28 try:
29 if int(sides) != 0:
30 if (
31 float(sides) % int(sides) == 0
32 ): # excludes the possibility of inputted floats being rounded.
33 return int(sides)
34 else:
35 return int(sides)
36
37 except ValueError:
38 print("Invalid input!")
39 return None
40
41
42# Picks a number that is at least of a certain size.

Callers 1

pickNumberFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected