+ 1

will it work without return! by using some variable names in line 2, i tried i couldn't make it worked😀

https://code.sololearn.com/cT1I5Cm6crLv/?ref=app

19th May 2021, 7:12 PM
HĂ«llo Wörld🔰
HĂ«llo Wörld🔰 - avatar
2 RĂ©ponses
+ 3
visph Thank you brother really appreciate💙
19th May 2021, 7:28 PM
HĂ«llo Wörld🔰
HĂ«llo Wörld🔰 - avatar
+ 2
""" yes, you could, but to assign a global variable from inside a function, you must declare it with 'global' keyword... so, your code could either be: """ def seven_add(): global number number+=7 results = [] numbers = [1, 2, 3] for number in numbers: seven_add() results.append(number) print(results) # or: def seven_add(num): global res res = num+7 results = [] numbers = [1, 2, 3] for number in numbers: seven_add(number) results.append(res) print(results)
19th May 2021, 7:23 PM
visph
visph - avatar