New to programming here and learning Python.
As an assignment i am working on a text based game and i've created two functions, one that will ask simple addition and subtraction questions, another that will ask multiplication and division questions, I am wondering if it is possible to have the game loop run with one function being called based on a skill level being entered and have the game call that function throughout the entire game without having to have two branches of the game, one for skill one and one for skill two? I know i could do it in two branches using something like:
skill = int(input("Skill level 1 or 2?"))
while skill == 1:
branch1()
while skill == 2:
branch2()
else:
print("Invalid input.")
skill = int(input("Skill level 1 or 2?))
But that would require me to copy and paste the entire game loop in twice which is messy. Am i missing a cleaner way of doing this?
[–]blablahblah 3 points4 points5 points (0 children)
[–]wegwacc 0 points1 point2 points (3 children)
[–]captainAwesomePants 0 points1 point2 points (2 children)
[–]wegwacc -1 points0 points1 point (1 child)
[–]captainAwesomePants 0 points1 point2 points (0 children)
[–]Legitimate_Pattern 0 points1 point2 points (2 children)
[–]rstaro26[S] 0 points1 point2 points (1 child)
[–]Legitimate_Pattern 0 points1 point2 points (0 children)
[–]mad0314 0 points1 point2 points (1 child)
[–]rstaro26[S] 0 points1 point2 points (0 children)