-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecursion problem1a.py
More file actions
29 lines (26 loc) · 960 Bytes
/
recursion problem1a.py
File metadata and controls
29 lines (26 loc) · 960 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
#1a, The "cumulative max" or cmax is an operation we can apply to a list.
#It means the max of the list up to a given entry.
#The left-hand cumulative max is a new list where the ith entry is the max
#of entries 0 through i-1.
#The right-hand cumulative max is a new list where the ith entry is the max of
#entries i though the end.
theList = [1]
def askFor():
status = input("Give me a whole number. Type finished to stop.")
if(status == "finished"):
del theList[0]
#disliked the empty list so the 1 is a placeholder that's removed before
#the list is returned
print(theList)
return(theList)
else:
status = int(status)
check = theList[len(theList)-1]
#needs to check the item that's last in the list's value
check = int(check)
if(status > check):
theList.append(status)
else:
theList.append(check)
askFor()
askFor()