I\'m trying to write a short program which allows the user to input a list of numbers into an input() function, and then using the add_25 function add 25 to each item in a list.
Besides all the input()
aspects covered in the other answers, I'd like to add this completely different aspect:
Your function add_25()
is probably not supposed to change its input. Yours does, or tries to, and fails because tuples do not allow that.
But you actually do not have to change the input (and you should not, because this is not good style due to its ugly side-effects). Instead you could just return a new tuple:
def add_25(mytuple):
return tuple(x + 25 for x in mytuple)
This way, nothing is assigned to a tuple, just a new tuple is created and returned.