[Tutor] Coding question: How to call a function when the function is assigned a variable

Historitical Show histolitician at gmail.com
Sun Oct 22 20:40:06 EDT 2017


This is what I have so far. I am trying to make it so that it

measures how long it takes the user to get 20 scores.

If it takes 1 second or less,then then they are obviously

spamming ENTER by holding it down. I want tocheck and if they

are holding down the key, then it will pause the program.

Here is what I have so far:

import time
coins = 0
score = 0
cptype = 1
start = time.time()
end = time.time()


def main():
    global coins, score, cptype, start, end
    if start - end <= 1 and coins == 20:
        print()
        print("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$")
        print("                 STOP!                   ")
        print("    You can't hold down the ENTER key!   ")
        print("         Please type correctly!          ")
        print("   The game will now pause temporarily   ")
        print("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$")
        print()
        time.sleep(5)
    else:
        start is True
        type = input("")
        if type == "":
            score = score + 1
            coins = coins + cptype
        end is True
        print(start - end)
        main()


main()


More information about the Tutor mailing list