so I have this code
data = input()
m = data.split(',')
for i in range(0, len(m)):
print(int(m[i]) )
but then when i run it and type in “1,2,3”, i get this error:
print(int(m[i]))
ValueError: invalid literal for int() with base 10: '"1'
what did i do wrong?
using python 3
As you have your code, the input you type in should be numbers separated by commas. You do not have to include the quotes, just type
1,2,3and nothing else. You only need the quotes only if you are writing actual code writing string literals. In this case, you are just taking input and it will already be strings.The problem is that you are typing literally
"1,2,3"and it tries to parse the first int the string,"1which is invalid.