I want to cast elements in a list (string to integer) Can't find what my mistake is. I just get strings. Some other post answers suggest list comprehensions, but, being a newbie, I prefer understanding why this more basic approach doesn't work, before learning list comprehensions.
Thanks for your help.
(Using Python 3)
I tried:
while True:
userInput=input("Write space-separated numbers: ")
listNumbers=userInput.split()
for i in listNumbers:
int(i)
print(type(listNumbers[0]))
Also tried:
for i in listNumbers:
i=int(i)
I expect the type(listNumbers[0]) or whatever index number to return integer but the output is still a string.