-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrings.py
More file actions
51 lines (39 loc) · 1.75 KB
/
strings.py
File metadata and controls
51 lines (39 loc) · 1.75 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
# Kyutza Lopez
# Assignment 4.1
# COP 2500
# Nov 3, 2022
schedule = list()
dropped = []
print ("You aren't currently taking any courses.")
# loops everything as long as the length of schedule doesn't reach 5
while (len(schedule) != 5):
courses = input("What courses would you like to take? ")
# exit loop
if (len(schedule) == 5):
print("Done!")
break
else:
courses = courses.split(",")
for index in range(len(courses)):
courses[index] = courses[index].strip().title()
# creates the updated schedule after each new input
schedule = schedule + courses
print("You are currently taking these courses:")
for index in range(len(schedule)):
print(str(index+1) + ": " + str(schedule[index]))
# str(index+1) creates the numbers for the list, str(schedule[index] print out the input as string
# performs these functions if the legnth of the schedule reaches 6
while (len(schedule) > 5):
dropped = input("What courses would you like to drop? ")
dropped = dropped.split (",")
for index in range(len(dropped)):
dropped[index] = dropped[index].strip().title()
# creates a new list that will be deleted from the schedule
# list made from dropped courses that will be detected from schedule
dropped.append(dropped[index])
if dropped[index] in schedule:
schedule.remove(dropped[index])
# detecting dropped courses from schedule, and removing them
print("You are currently taking these courses:") # reprinting new schedule
for index in range(len(schedule)):
print(str(index+1) + ": " + str(schedule[index]))