+ 1
using variables from function
def yet(yut): yut="yaaah" return yut print(yut)uuu This code output is NameError: yut is not defined is there any way I can use variable yut outside function yet?
6 Answers
+ 1
Still a newb but canât you just declare it as a global variable?
0
Ben Bryant I've never heard those I'll look it up thanks
0
No prob. I think you just use the work âglobalâ before it. But theyâre frowned upon for reasons I donât yet understand đđ»
0
you can have def yet():
and print(yet)
0
Yes of course! Use the yet function as an output. This made my life a lot easier when trying to write a function that rolled a dice because I couldnât get the dice roll out of the function and into the main code. Now I just assign the result of the func to a variable and call the variable
0
I'll experiment with these suggestions thanks