+ 5
input() always returns a string. If you want it to be an integer, you need to convert it.
8th Oct 2022, 3:36 PM
Lisa
Lisa - avatar
+ 1
Your list only contains integer, there isn't any other type. Suppose you had a list [1, "1"]. The user input is "1". How would you know if the user means 1 or "1"?
8th Oct 2022, 3:47 PM
Lisa
Lisa - avatar
+ 1
Why do the numbers in the list need to be integers? You can store them as strings... If not you need to convert it some way or the other.
8th Oct 2022, 4:00 PM
Lisa
Lisa - avatar
+ 1
use typecasting.. userinput_ = int(input()) or, userinput_ = input() int(userinput_) try this, once it will work
9th Oct 2022, 12:07 PM
filibuster
filibuster - avatar
+ 1
''' ice , or you can temporarily map all the elements to str in the if statement. Then you will be comparing string to string, not int to string. It is not the append not working.It is because in your if statement, you are comparing string to int. ''' userinput_ = input() list = [1, 2, 3] list.append("spam") if userinput_ in map(str, list): list.append("eggs") print(list) ''' input 1, 2 or 3 will append "eggs" '''
10th Oct 2022, 9:35 AM
Bob_Li
Bob_Li - avatar
0
As i slightly remember, GOTO keyword of C is used to position the cursor before printing out something on the screen. But now, i don't exactly remember tge syntax how to implement this C keyword GOTO. Is there anyone can help about this syntax. Thank you for those who will patiently answer.
9th Oct 2022, 8:59 PM
Liza Tolentino