+ 1
[SOLVED] range
i just learnt about range and i wrote a code as practice but got a negative answer. can anyone explain why. code attached. https://code.sololearn.com/c8xhlFV05I6d/?ref=app
3 Réponses
+ 6
atom = int(input("Please submit a number (1-10): "))
print("\nIs that your lucky number?" if (atom <= 10 and atom >= 1) else "Your submission was invalid.")
The ".lower()" method used is not used with numbers. Why would you try to convert a number to "lowercase"?
Also, you're storing the input as a string, versus an integer.
+ 5
That's because input returns a string. You have to convert it to integer to be able to compare it to other integers (range elements).
Try:
atom = int(input("choose a number from 1-10! "))
+ 3
thanks CipherFox and Siekierzyński.