CGSC 1005 Lecture 13: COMP SCI Oct. 31

25 views2 pages

Document Summary

Nested loops prints each individual element of each individual string and prints. Still here" after each iteration of the outer loop for every string. To date we have focused on lists whose elements themselves are not lists either numbers or strings. We can traverse access each individual element by using loops. Caveat about modifying lists, using append the list must already exist. Caveat about modifying lists, using [ pos ] the position must be valid. Append adds an element onto the end of an existing list. Will look for bob" in each inner element and when it find it print aha". We can access elements of the nested lists using the [ ] operator. When a for loops runs, python grabs the next element of a sequence and assigns it to the loop variable. The type of that loop variable depends on what the list contains. If the list contains lists then ele will be a list.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents