-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForLoops.py
More file actions
39 lines (26 loc) · 890 Bytes
/
ForLoops.py
File metadata and controls
39 lines (26 loc) · 890 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# will print the range of 5-10 as a list
print(list(range(5,10)))
for iteration in range(10):
print(iteration)
# prints out all of the things in the range
print("***")
my_list = ["lovely", "duck", 10, True]
# prints out all the individual items in a list seperately
for i in range(len(my_list)):
print (i)
print (my_list[i])
# can also use for element in my_list: print (element) but is not the pref
print("***")
# while looooop
status = input("Enter an int or write DONE \n")
#\n is just for aesthetic reasons
result = 1
while (status != "DONE"):
# turning the status into an integer so it can be multiplied by the
# initial 1
result = result * int(status)
# needs to re-ask
status = input("Enter an int or write DONE \n")
print(result)
# will only print the final result
# also I guess in the global namespace so result can be called