Learning python through pym 14-08-2019
Day 4
PS: These are notes, there could be grammar error and spelling errors.
for loops
For loop over a list goes as follows:
range() function
range function creates lists based on parameter passed in function``py
| |
Continue statement
Just like break is use to break loop, continue is used to continue loop towards iteration without further execution A combined example.
Data Structures
Lists
Few other things with lists:
| |
Same way we have .reverse, .remove using append we can append another list to existing list as a element of the list
There is another method call .extend which would add element of second list as element of new list
| |
Using lists as stack and queue
Stacks work as LIFO(Last In First Out) and queue work on FIFO(First In First Out)
| |
Note: .pop removes element and return removed element while append just add element doesn’t returns anything