[SOLVED] range | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

6th Apr 2018, 6:26 AM
Doe Dare Oladimeji
Doe Dare Oladimeji - avatar
3 Answers
+ 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.
6th Apr 2018, 6:32 AM
Fox - avatar
+ 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! "))
6th Apr 2018, 6:33 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 3
thanks CipherFox and Siekierzyński.
6th Apr 2018, 6:41 AM
Doe Dare Oladimeji
Doe Dare Oladimeji - avatar