قسمت remove و قسمت replace باگ دارد
به این شکل که:اگر درسی حذف بشه و یا جالیگزین بشه واحد اون درس تغییری نمیکنه در لیست دانشجو
courses = ['math', 'physics', 'network', 'programming', 'language']
units = [3, 2, 3, 3, 2]
stList = []
stUnit = 0
print('Hi students,wellcome')
print('list of cuorses with units is:')
while True:
print('math <3 unit>___physics <2 unit>___network <3 unit>___programing <3 unit>___language <2 unit>')
print('your chosen courses: ', stList ,' your chosen unit: ', stUnit)
choose = input('enter the courses you want to select, < you dont let to choose more than 10 units>,enter (e) for exit :' )
while choose in stList:
choose = input('Repetitive course try againe: ')
if choose == 'e':
break
if choose == 'e':
break
if choose in courses:
index = courses.index(choose)
if stUnit + units[index] > 10:
print('you dont let to choose more than 10 units <try againe>')
else:
stList.append(choose)
stUnit += units[index]
else:
print('invalid entery,your choose is out of the list <try againe>')
print('your choised list of courses is: ',stList)
print('your choised list of units is: ',stUnit)
while True:
if input('for finish enter <f>, else if you want chenge the list (add,remove,replace) enter another key: ') == 'f' :
break
else:
print('your chosen courses: ', stList ,' your chosen unit: ', stUnit)
change = input('for change,enter the number of option>>> 1)add____2)remove___3)replace : ')
if change == '1':
add = input('enter the course you want to add: ')
while add in stList:
add = input('Repetitive course try againe <enter (e) for exit> : ')
if add == 'e':
break
if add in courses:
index = courses.index(add)
if stUnit + units[index] > 10:
print('you dont let to choose more than 10 units <try againe>')
else:
stList.append(add)
stUnit += units[index]
else:
print('invalid entery,your choose is out of the list <try againe>')
elif change == '2':
rem = input('enter the course you want to remove: ')
if rem in stList:
stList.remove(rem)
else:
print('invalid entery,your choose is out of the list <try againe>')
elif change == '3':
replace1 = input('enter your course of list that you want change: ')
if replace1 in stList:
replace2 = input(f'enter your course that you want replace with {replace1}: ')
while replace2 in stList:
replace2 = input('Repetitive course try againe <enter (e) for exit> : ')
if replace2 == 'e':
break
if replace2 in courses:
index = courses.index(replace2)
if stUnit + units[index] > 10:
print('you dont let to choose more than 10 units <try againe>')
else:
stList = list(map(lambda x:x.replace(replace1,replace2), stList))
stUnit += units[index]
else:
print('invalid entery,your choose is out of the list <try againe>')
else:
print('invalid entery,your choose is out of the list <try againe>')
else:
print('invalid entery,your choose is out of the list <try againe>' )
print('your choised list of courses is: ',stList)
print('your choised list of units is: ',stUnit)
input()