Python 2 raw_input to list type -
i used input() in program, convert input list type, read should use raw_input() instead.
i'm trying let user input vectors in form (4,4),(2,5),(1,6) using input() worked.
i used:
vectors = list(input('enter vectors\n'))
after changing raw_input() list elements in str
'(' '4' ',' '4' ')' ',' '(' '2' ',' '5' ')' ',' '(' '1' ',' '6' ')'
how can input converted list if used input()? should go using input() instead?
assuming input data in form 1,2
work:
vectors = [] print ('enter vectors') while true: = raw_input('') if == 'q': break else: vectors.append(tuple(int(c) c in a.split(','))) print vectors
Comments
Post a Comment