Can you stop through conditional statements while executing certain functions in Python?

Asked 2 years ago, Updated 2 years ago, 18 views

Let me give you an example.

sum=0
cml=0
def abc():
    def is nada ():
        global sum
        sum+=1
        if sum==10:
            print("Hi!")
            sum=0
    def 123():
        global cml
        cml+=1
        if cml==100
            sum=0
        .
        .
        .
    123()
    If specific conditional syntax ():
        It's ABC()
abc()

If there's a code like this, let's create a program that runs under the if specific conditional syntax and ends 123() at the same time, but I don't know what to do.

The desired action with this code is, for example, if you press a specific key on the keyboard for 3 seconds, the output will be 1, but if you press and release it for 2 seconds, it will be determined that it is not recognized, and you want to return the time to 0 seconds.

There must be a code that does this, but I don't know the exact name, so I'm leaving a question like this because I don't know what code to use.

python

2022-09-22 19:41

1 Answers

If you want to separate the two functions, search for asynchronous. However, I think the function you mentioned can be implemented by adding variables separately to check synchronously and initializing other values if certain conditions are met certain conditions.


2022-09-22 19:41

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.