How can I call tuples on my code? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 1

How can I call tuples on my code?

I'm trying to do a calculator in Python, and I use a tuple for keep the signals, but when I did the condition for check if signal is in tuple, but it came this error "tuple is not callable". Also can I minimize this code, without leave the main functions Code:

21st Oct 2021, 11:53 PM
Katdotbrush - avatar
2 Antworten
+ 3
Don't use round parentheses. Use square brakets instead. On line 16.
22nd Oct 2021, 12:20 AM
Stefanoo - avatar
+ 1
As Stefanoo has stated, square brackets are used for indexing of iterables, including tuples. signals[0] Also, try changing the way the if condition reads to; if signal not in signals: The result is the same, but it is more Pythonic and readable.
22nd Oct 2021, 3:40 AM
ChaoticDawg - avatar