+ 3

[SOLVED] I have a problem

I want user input which looks like: 4, 75, 31, 18 to be put in a list as: list = ["4", "75", "31", "18"] or like this: list = [4, 75, 31, 18] But all im getting is something like: list = ["4, 75, 31, 18"] and list = ["4", ",", " ", "7", "5",... and so on.

21st Apr 2018, 4:01 AM
Rok G
3 odpowiedzi
+ 7
Listwhatever=Userinput.split(“,”)
21st Apr 2018, 4:13 AM
syul
syul - avatar
+ 3
Also if you want it in int instead of string. List1=[int(x) for x in input().split(',')]
21st Apr 2018, 5:04 AM
Louis
Louis - avatar
+ 2
Thank you syul it works as needed. :)
21st Apr 2018, 4:23 AM
Rok G