I am studying Python and now I'm doing a small project on my own. The for loop in the second function is not run through the whole code. When I run the code I get just the last element of the dictionary.
In order to solve it I have tried to use while
but I got the same answer.
def enter_task():
global num_task
num_task = int(input("Please, enter number of tasks: "))
calendar = {}
for i in range(0, num_task):
global task
task=input("Please, enter task: ")
set_time = input("Please, enter time for {}: ". format(task))
calendar[task] = set_time
print(calendar)
def conclusion():
count = 0
for i in range(0, num_task):
is_done = input("Is task {} completed? Enter Yes/No: ".format(task))
if is_done == "yes":
count += 1
return count
print('Nicely done. {} of {} tasks were completed today'. format(count, num_task))
When I call conclusion, the input is_done
is shown just once and the task is equal to the last task I typed in the function enter_task
. Also the count
is not counting and the statement is not printed. The input is_done
should appear as many times as nun_task
and each time with a different task on it.