Function arguments | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Function arguments

hey guys, i have got a little problem with this part of a code: it has to change the default value of an argument of a function https://code.sololearn.com/cNNkMA0asY22/?ref=app the commented part doesn't work, instead the code below run correctly is it an 'elegant' solution? is there a better way to make this code run correctly?

18th Jul 2017, 9:27 AM
Daniele
Daniele - avatar
2 Answers
0
if it is a global variable why pass it? globalVal = 2 def f(): val=globalVal print(val) f() globalVal = 7 f()
18th Jul 2017, 10:49 AM
Kedar Kale
Kedar Kale - avatar
0
you're right hahah, i wrote it on my laptop and i report here and i was wrong while i was copying @Kedar Kale
18th Jul 2017, 11:24 AM
Daniele
Daniele - avatar