I have a problem in many of my scripts, this is a stripped down version if the problem code:
list1 = ["item1","item2"]
def test():
if 1 == 1:
var1 = input ("var1? ")
if var1 not in list1:
print("please enter existing item")
test()
print(var1)
test()
It gives weird outputs like
var1? 23 please enter existing item var1? 4 please enter existing item var1? 23 please enter existing item var1? 2 please enter existing item var1? item1 item1 2 23
23
Why does it not just overwrite var1? How can I work around this in a script? Keep in mind that I need to use var 1 down the same function (and other places) elsewhere, so I do need to assign it to a variable.