cant get a variable to pass back to the main function in python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

cant get a variable to pass back to the main function in python

in my d&d 5e game when choosing a background for the character I call a fuction because it seemed easier at the time now i cant get the variable of background to pass back to the main function ill leave a link with the part of the main function that is in question and a sample of the function it is calling https://code.sololearn.com/c16WHT5n1jGP/#py

28th Nov 2020, 9:11 PM
David Aseltine
David Aseltine - avatar
4 Answers
+ 2
You need to call the function in order to get it to operate upon the contents. Maybe you could set up separate functions to run the details of each of your character classes, and use the main() to control the selection flow.
28th Nov 2020, 9:51 PM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
I had a quick look at your sample. First thing I noticed was the main() function was not being called. Then I started to get an error stating Classs was not defined, which may tie back to a previous section of your code. Good luck
28th Nov 2020, 9:41 PM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
Rik Wittkopp that is only a small sample of a bigger program I just wanted to highlight the problem areas I could post the whole code but it won't run in the playground. If I call back the main() function wouldn't that send me back to the top of the program? The function and variable in question are about 100 lines into the program
28th Nov 2020, 9:47 PM
David Aseltine
David Aseltine - avatar
+ 1
Rik Wittkopp I'll look into that thank you
28th Nov 2020, 9:58 PM
David Aseltine
David Aseltine - avatar