Python and variables

Why can python have two of the same name variable but produce different outcomes?

For example:

#Greeting
message_string = “Hello there”
print(message_string)

#Farewell
message_string = “Hasta la vista”
print(message_string)

Each time we define the variable, we give it a different value. That is perfectly normal in programming. We have variables for that exact reason. They are only labels, remember.

1 Like