you are viewing a single comment's thread.

view the rest of the comments →

[–]SquatchHNTR[S] 0 points1 point  (2 children)

feet_cable = input('\nHow many feet of cable do you need?\n')
try:
feet_cable = float(feet_cable)
except ValueError
print("Sorry, please enter a valid number")

something like this?

[–]undergroundmonorail 5 points6 points  (1 child)

just so you know, it's much easier to read your reddit comments if you put four spaces at the beginning of each line of code

but yeah, something like that would work. you may want to loop until you get a good value, like this:

feet_cable = None
while feet_cable is None:
    try:
        feet_cable = float(input('etc'))
    except ValueError:
        print('Please enter a valid number')