python3 Py3: Detect string in input and act on it
Go to solution
Solved by WereCatf,
Just now, TheLewisS1 said:3.7.3. Just found it's a 3.8 feature. I'll see if i can update.
Sorry, I forgot that the walrus-operator was only introduced in 3.8. For earlier Python-versions, it'd be:
eventsList = ["FIRE", "TAMP", "INTRUDER", "FAULT"] event = input() if(event in eventsList): decipher_act(event, 1)
Not a big difference, but I like using the walrus-operator because it makes the code ever slightly more readable.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now