[Tutor] how to use int and split() simultaneously
surya k
suryak at live.com
Thu Dec 8 13:33:25 CET 2011
This is something I am trying to do..
Say, we are entering a string "1 2 3 4 5".so, I want to assign the numbers directly as numbers. how can I do it?
I could put that numbers as string but not as number..
strNum = raw_input('enter:').split()
I can convert the list into numbers by doing this...
for i in range(len(strNum)): strNum[i] = int(strNum[i]).
but I feel, its a long process. How can I do it in the shortest possible way??
More information about the Tutor
mailing list