Jan-11-2021, 11:38 AM
Hello everyone, I hope you are having a great day.
Here's a simple question.
I have a dictionary:
I'm trying to get a result like this:
Displaying the keys and their values, and if the value is less than 70, add "(Failed)"
Jane 90
Max 88
David 65 (Failed)
Sarah 57 (Failed)
Vi 62 (Failed)
(or in any other format that returns the same result)
This is how far I have gone!
Here's a simple question.
I have a dictionary:
1 |
dictName = { "Jane" : 90 , "Max" : 88 , "David" : 65 , "Sarah" : 57 , "Vi" : 62 } |
Displaying the keys and their values, and if the value is less than 70, add "(Failed)"
Jane 90
Max 88
David 65 (Failed)
Sarah 57 (Failed)
Vi 62 (Failed)
(or in any other format that returns the same result)
This is how far I have gone!
1 2 3 |
for i in dictName.values(): if i < 70 : print (i, "(Failed)" ) |
Output:65 (Failed)
57 (Failed)
62 (Failed)
Thank you in advance for all the answers.