+ 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: https://code.sololearn.com/c1HEHbmR01oO/?ref=app
2 Antworten
+ 3
Don't use round parentheses. Use square brakets instead. On line 16.
+ 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.