MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/PythonProjects2/comments/1g5iqba/what_will_be_the_output_of_this_code/
r/PythonProjects2 • u/rao_vishvajit • Oct 17 '24
14 comments sorted by
2
In line 3 it calls mydict[‘e’] when it hasn’t been defined yet so it would cause an error.
2 u/rao_vishvajit Oct 17 '24 It will not be caused an error because a new key e will be created in the dictionary. 1 u/Ok_Succotash79 Oct 17 '24 I gotta try this 1 u/Ok_Succotash79 Oct 17 '24 Now that I run it, it makes sense 3 u/Patbig Oct 17 '24 The , 0) after the e says if no key is found make it 0. I think. 2 u/Caligapiscis Oct 17 '24 You're right, the second parameter to the get function is an optional one specifying a value to return if no value is foundhttps://www.w3schools.com/python/ref_dictionary_get.asp
It will not be caused an error because a new key e will be created in the dictionary.
1 u/Ok_Succotash79 Oct 17 '24 I gotta try this 1 u/Ok_Succotash79 Oct 17 '24 Now that I run it, it makes sense
1
I gotta try this
Now that I run it, it makes sense
3
The , 0) after the e says if no key is found make it 0. I think.
2 u/Caligapiscis Oct 17 '24 You're right, the second parameter to the get function is an optional one specifying a value to return if no value is foundhttps://www.w3schools.com/python/ref_dictionary_get.asp
You're right, the second parameter to the get function is an optional one specifying a value to return if no value is found
https://www.w3schools.com/python/ref_dictionary_get.asp
4
A
Can anyone help me with a python programme for a assignment oks
1 u/Maleficent_Media_330 Oct 19 '24 Yes, I'm here for that.
Yes, I'm here for that.
The value of final my_dict is option A
In my opinion, it is A
2
u/Ok_Succotash79 Oct 17 '24
In line 3 it calls mydict[‘e’] when it hasn’t been defined yet so it would cause an error.