arrays - 'tuple' object has no attribute 'rstrip' python -
i writing python program takes in user input int array later sorted. have compiled program on machine, however, cannot compile correctly on unix server. python compiler on machine version 3 while believe server may running on python 2.6. i'm not sure underlying issue.
list = input('enter numbers in array commas: ').rstrip() #this line being flagged list = list.split(',') print(list) my error:
attributeerror: 'tuple' object has no attribute 'rstrip'
you using python2, in input() equivalent eval(raw_input()). evaluating input (which suppose 1, 2) tuple - has no rstrip attribute.
fix code using raw_input instead of input. give string can use rstrip on.
i'd suggest use variable name in place of list because shadow built in list.
Comments
Post a Comment