Let’s check out some exercises that will help understand tuples better.
Assign the first element of the tuple to answer_1 on line 2
tuple[index]
Correct syntax to call a tuple’s element is brackets with the index number inside next to the tuple’s name:
This time print the third element of the tuple.
0,1,2 … Third element is index 2: [2]
Print the second from the last element of the tuple.
Second from last element has index of -2.
*Includes 14 more programming languages, inspirational tools and 1-on-1 consulting options.
Umut Sagir
Finance & Data Science Professional,
Founder of HolyPython
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4