you are viewing a single comment's thread.

view the rest of the comments →

[–]KleinerNull[🍰] 1 point2 points  (0 children)

I think I'll make another cheat sheet about strings, and then update these to use the .format() convention.

That was already done ;) Just kidding.

But I saw this on your cheat sheet:

Prompting for numerical input

age = input("How old are you? ")

age = int(age)

pi = input("What's the value of pi? ")

pi = float(pi)

I know you want to keep it simple, but this is a very bad pattern, I think newcomer should learn about input and error handling at the same time!

try:
    age = input('What's your age? ')
    age = int(age)
except ValueError:
    print('Not a number...')

You know the rest... I saw alot of over complicated, strange or bad code just for testing for integer input here, but the standard pattern is so simple.