How can I add an int to. List in python | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
- 1

How can I add an int to. List in python

8th Jan 2022, 12:42 AM
Nathan
3 Antworten
+ 4
list.append(<int>)
8th Jan 2022, 12:57 AM
Slick
Slick - avatar
+ 1
Nathan input method will always give you a string, if you want an integer you need to convert it using int( ). You can try: number = int(input( ))
8th Jan 2022, 12:18 PM
YoPycode
0
Input = input() #lets assume the input entered were integers Input = list(input) # it will be ['1','2'] instead of [1,2] now how do I make it [1,2]
8th Jan 2022, 12:10 PM
Nathan