Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

1.4.3. reassigning variables content introduction to computer science v…

Question

1.4.3. reassigning variables
content
introduction to computer science
variables
watch the video
00:00 / 04:07
fixing an error in a game
message
oh no we have an error! can you fix it?
your task: go ahead and fix the error in the program in the code editor so that there is no error.
main takeaways

Explanation:

Step1: Identify the error

The variable player is used in the print statements but is not defined.

Step2: Fix the error

We can either define player or use the defined hero variable instead. Here we use hero:

hero = "Josephine"
print("Welcome to Planet Python, " + hero + "!")
print("Congratulations, " + hero + " you are the hero!")

Answer:

hero = "Josephine"
print("Welcome to Planet Python, " + hero + "!")
print("Congratulations, " + hero + " you are the hero!")