1def main(): #defines the area in indents that will be triggered with main()#
2 print('hi')
3 yn = input('Wanna loop back to the start? ')
4 if yn = 'yes':
5 main() #loops back to where we defined main#
6
7main() #This starts the main loop, without this, main would just be defined but not run#
1my_list = [1, 2, 3]
2my_list.reverse() # my_list is modified
3print(my_list) # '[3, 2, 1]'
4my_revert = my_list[::-1] # my_list stays [3, 2, 1]
5print(my_revert) # '[1, 2, 3]'
6# Item by item reverse with range(<start>, <end>, <step>)
7for i in range(len(my_list), 0, -1): # my_list is [3, 2, 1]
8 print(my_list[i-1]) # '1' '2' '3'
9for i in reversed(range(len(my_list))):
10 print(my_list[i]) # '1' '2' '3'
1for x in range (0, 20 + 1, 5):
2 print(x)
3 if x == 20: break
4
5print('bob')
6
7"""
8output:
9
100
115
1210
1315
1420
15bob
16
17"""
18
19#I hope it helps! -Andrew Ma
20
21#make sure when you print bob don't indent or else
22it will think it is part of the for loop! :)
23