0
Convert string to integers
How to convert â2,3,4â to integers in python ?
4 RĂ©ponses
+ 1
First, you transform your string into a list of pure number strings.
You can use the string method split for it, which you call with ',' as argument.
Then, you can loop over your list and apply int() to each element.
0
num=[â1â,â2â,â3â,â4â,â5â,â6â,â7â,â8â,â9â]
for s in str:
if s in num:
print(int(s))
0
a=input("")
x=a.split(',')
for i in x:
print(int(i ))