How do I make a list and stop it with "=" sign, because I stop when number is negative, but I want to enter all numbers, positiv | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How do I make a list and stop it with "=" sign, because I stop when number is negative, but I want to enter all numbers, positiv

https://code.sololearn.com/c5bZIz6sqIN1/?ref=app

11th Jul 2020, 11:04 PM
TiTo90
TiTo90 - avatar
8 Answers
+ 3
yes, because = is not an integer. in this situation you need to: take strings check if that string is a = if not, change to integer and add to list
12th Jul 2020, 12:14 AM
Slick
Slick - avatar
+ 2
lista = [] while True: número = input("Give me another number: ") if número == '=': break lista.append(int(número))
11th Jul 2020, 11:25 PM
rodwynnejones
rodwynnejones - avatar
11th Jul 2020, 11:54 PM
Slick
Slick - avatar
12th Jul 2020, 12:08 AM
李立威
+ 1
Yeeeaahhh 👏👏👏 💪😎👍 thanks
12th Jul 2020, 1:11 AM
TiTo90
TiTo90 - avatar
+ 1
Hii
13th Jul 2020, 7:43 PM
Efrem Tadese
Efrem Tadese - avatar
0
Return error 😭😭😭
11th Jul 2020, 11:40 PM
TiTo90
TiTo90 - avatar
0
Uff, error again, it says: Traceback (most recent call last): (Adress in pc), line9, in <module> número = int(input("Give me another number: ")) ValueError: invalid literal for int() with base 10: "="
12th Jul 2020, 12:03 AM
TiTo90
TiTo90 - avatar