Loop With Python Tuple
Rushikesh J.
QA Automation Engineer @Vinz Global | Robot Framework | Manual Testing, Automation Testing | Python | Selenium | GIT | JIRA | Immediate Joiner | API Testing Using Postman | Jenkins
?Using loop with Tuple, we can iterate one by one items of a tuple.
?We can check all the items one by one to get required items in different ways.
Example
?Finding specific student name in a student that stored in tuple.
?Getting EVEN number from tuple which contain numbers.
?Getting ODD number from tuple which contain numbers.
?Analyzing different items from a tuple.
?Perform different operations to a specific item in a tuple.
Example
language? = ('Python', 'C++', 'JavaScript', 'C', 'Java', 'HTML‘)
for i in language:
? print(i)
Why need to use Loop with Tuple
?Using loop, we can analyze all the items or elements of a tuple
?Using loop, we can display all the items to screen
?Using loop, we can find any specific items or element from a tuple
?A lots of problem can be solve using loop with tuple
Changing element while using loop with tuple
language? = (3, 5, 1, 51, 6, 7, 8, 12)
Displaying Element:
for i in language:
? print(i)
Changing Element
for i in language:
? if i == 3? :
? ???? language[i] = 4 # you will get an error