Logo
/
Programming
/
Python Course
/

Changing variables

Python: Changing variables

The word “variable” itself suggests that it can be changed. And indeed, the values of variables can change over time within the program.

For example:

# greeting 
greeting = 'Father!'
print(greeting)  # => Father!

greeting = 'Mother!'
print(greeting)  # => Mother!

The name remained the same, but there were different data inside. Note that variables in Python require no special declaration. Instead, a variable is declared when it is first used in a program.

Variables are a powerful yet risky thing. You can't be sure right away what'll be inside it - first you have to analyze the code that comes before the variable. This is what developers do during debugging, when they try to figure out why the program doesn't work as intended.

Instructions

In the exercise, a variable is defined with a string inside it. Override the value of this variable and assign it a string in which the characters of the original string are arranged in reverse order.

Note: in this assignment, you'll have to write code between lines with comments # BEGIN and # END (we mentioned it before, but this is the first time you've come across this format).

If you've reached a deadlock it's time to ask your question in the «Discussions». How ask a question correctly:

  • Be sure to attach the test output, without it it's almost impossible to figure out what went wrong, even if you show your code. It's complicated for developers to execute code in their heads, but having a mistake before their eyes most probably will be helpful.
Found a bug? Have something to add? Pull requests are welcome!