How to input numbers
Since you guys are better than me do you mind telling me how to put a code for when I put in a command for it only to accept numbers
Muffinlavania
You can als do this:
number = input("Enter a number") if number.isdigit():#If the input is a number: print("yay") else: print(":( i wanted a number")
Of course you can loop it and stuff but that is the foundation
thenullified
while True: s1 = input('number goes here') try: int(s1) except: print('pls enter a NUMBER') else: [*insert rest of code here*]
CodeQueen4123
Because it doesn’t say error when I don’t put numbers
You can surround a casted input statement with a try - except block and a loop that just does another input if the cast fails.
@Highwayman
Thank you I will try that
@CodeQueen4123 👍
@Highwayman
Hey I had to run an errand do you mind showing me what it should look like hope u r still on
@Highwayman
Nvm I found out 🙏🏾 for ur help tho