run a statement only in the first loop python code example
Example 1: for loop python start at 1
# starts at 1 up to, but not including, 5
for i in range(1, 5)
print(i)
Example 2: python loop back to start
def main(): #defines the area in indents that will be triggered with main()#
print('hi')
yn = input('Wanna loop back to the start? ')
if yn = 'yes':
main() #loops back to where we defined main#
main() #This starts the main loop, without this, main would just be defined but not run#
Example 3: python every other including first
a = [1, 2, 3, 4, 5]
a[1::2]
# returns 2, 4
a[::2]
#returns 1, 3, 5