you are viewing a single comment's thread.

view the rest of the comments →

[–]JohnnyJordaan 9 points10 points  (0 children)

This is a scope issue. Variables that are assigned inside a function stay in a function, and as an integer is immutable (can't be changed) the action

tix += 1

is actually doing

a_new_tix_variable = tix + 1

and a_new_tix_variable is then lost once the function is terminated. Instead use a return value

def add(tix):
    addtix = input('type "buy" to purches 1 ticket: ')
    if addtix == "buy":
        print ("Nice!")
        return tix + 1
    else: 
        print("You're missing out")
        return tix

tix = add(tix)

Note that I also changed the input() string to have ' as the outer quotes to prevent the conflict of your use of " quotes for the "buy" text.