In pyhton Using the students dictionary provided below # This dictionary provided for you students = { 'S1' : True, 'S2' : False, 'S3' : True, 'S4' : False, } write a for loop that loops across the dictionary and collects all subject numbers (ex. 'S2') where the dictionary value is False. Imagine, for example, the dictionary indicates whether a student has completed an assignment, and we wanted to get a list of the students who had not yet completed the assignment. To answer this question, use a for loop across the students dictionary. You then need to get the associated value in each iteration, and check if it is True. If it is True, you can use continue to skip ahead to the next iteration. Otherwise, append the subject number (i.e. 'S2') to a list called incomplete.
In pyhton
Using the students dictionary provided below
# This dictionary provided for you
students = {
'S1' : True,
'S2' : False,
'S3' : True,
'S4' : False,
}
write a for loop that loops across the dictionary and collects all subject numbers (ex. 'S2') where the dictionary value is False.
Imagine, for example, the dictionary indicates whether a student has completed an assignment, and we wanted to get a list of the students who had not yet completed the assignment.
To answer this question, use a for loop across the students dictionary. You then need to get the associated value in each iteration, and check if it is True. If it is True, you can use continue to skip ahead to the next iteration. Otherwise, append the subject number (i.e. 'S2') to a list called incomplete.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images