I am trying to turn the text of a text file into a tuple. I'm a Python beginner and assume this code will be not as straight forward as it could be and thats okay with me (for now). All I am trying to do is making the tuple numbers_bank a global value so I can access it outside the function.
Printing the tuple from inside the function works but it doesn't work outside the function.
Can someone tell me what I am doing wrong? (It is a requirement that the output is a tuple, otherwise I would have changed it to a list and just append the elements.)
global numbers_bank
def read_numbers():
file = open("numbers.txt")
num = file.read().split(",")
num_new = [s.replace("[", "") for s in num]
numbers_bank = [a.replace("]", "") for a in num_new]
tuple(numbers_bank)
read_numbers()
print(numbers_bank)