+ 1

What is the bug of my code

user_input=input() if type(user_input)==int print("please enter a number") else: if not type(user_input)==int print("invalid input.please enter a number") if type(user_input)==int print("please enter a number") else: if not type(user_input)in (int,str) print("invalid input.only numbers and letters are allowed")

12th Aug 2023, 9:08 AM
Aminu Sani
2 odpowiedzi
+ 5
You didn't use colons at the end of the if statement's condition and you haven't indented you code correctly
12th Aug 2023, 9:13 AM
Aweneg Rooney
Aweneg Rooney - avatar
+ 3
Aminu , sorry to say, but there are too many issues in your code. > it looks like you are not too familiar with some things that are being taught here. it is recommended to learn from the *introduction to python* tutorial first. you also should practice what you have learned. >it makes not much sense if you try to force your learning pace, and than need to ask for help. > learning takes its time and effort, and you also need to build up some experience. so be patient and continue lerning.
12th Aug 2023, 5:21 PM
Lothar
Lothar - avatar