Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Changing a the value of a string variable

I'm new to python, and I just want to know a way of changing a set string variable.

For example:

name ='school'

How would I go about changing this if I wanted to use the name variable for a different value like George, Ben, Jess, Katie, etc.

like image 988
belegarath Avatar asked Sep 14 '26 21:09

belegarath


1 Answers

You can assign a new value to a variable in the same way you originally assigned a value to it: Using the assignment operator, =.

name = 'school'
print 'the current value of name is:', name
name = 'George'
print 'the current value of name is:', name

Result:

the current value of name is: school
the current value of name is: George
like image 71
Kevin Avatar answered Sep 17 '26 23:09

Kevin