+ 1

Please help to create two diffrent functions!

in my hangman.py game I defines a cls() function inside play() function and now I am troubling to separate them without getting any problems.. please help me to separate that two functions.. My code : https://code.sololearn.com/c99iLxxZG8Ud/?ref=app

24th Apr 2021, 12:13 PM
Ratnapal Shende
Ratnapal Shende - avatar
2 Réponses
+ 1
The short version is that the function within the function needs to be defined outside it, but accept as parameters any situational data from the outside that it will need to run. Then, the other function can call it and pass it the necessary data.
24th Apr 2021, 5:28 PM
Wilbur Jaywright
Wilbur Jaywright - avatar
+ 1
You may be defining functions when you don’t need to. Functions should encapsulate code that gets run in different places of the program over and over, such as getting a choice from a list of options.
24th Apr 2021, 5:28 PM
Wilbur Jaywright
Wilbur Jaywright - avatar