Beginning of program assignment has a bug collector input the amount of bugs collected each day of the week then outputs the total number of bugs in a print statement. My professor has forbid us from using 'while true' and 'break'. Assignment requires the loop finishes only when the user inputs 'done' so I wrote an input statement asking the user to affirm, otherwise the code loops. Did I appropriately write the body of the loop?
def bug_collector():
myInput = 0
while myInput != 'done':
Monday = int(input('How many bugs did you collect on Monday?: '))
Tuesday = int(input('How many bugs did you collect on Tuesday?: '))
Wednesday = int(input('How many bugs did you collect on Wednesday?: '))
Thursday = int(input('How many bugs did you collect on Thursday?: '))
Friday = int(input('How many bugs did you collect on Friday?: '))
Saturday = int(input('How many bugs did you collect on Saturday?: '))
Sunday = int(input('How many bugs did you collect on Sunday?: '))
weekTotal = Monday + Tuesday + Wednesday + Thursday + Friday + Saturday + Sunday
myInput = input("If you're finished, enter 'done'. If not, enter 'no' to restart: ")
if myInput == 'done':
if weekTotal == 0:
print('You did not collect any bugs this week...')
elif weekTotal == 1:
print('You collected only {} bug this week! '.format(weekTotal))
elif weekTotal > 1:
print('You collected {} bugs this week! '.format(weekTotal))
if myInput == 'no':
bug_collector()
print('Done!')
#Main Code
bug_collector()