0

What is the difference in variable and literal string ?

Here def f(): print(res) #res is just given vairable name def hi_there(hithere): print("hi there") res="hi there !" f() print(res) hi_there (res) #given below function is abother part just slightly changing the string ("hi there ") #into hi there def f(): print(res) #res is just given vairable name def hi_there(hithere): print(hithere) res="hi there !" f() print(res) hi_there (res) https://code.sololearn.com/c3Ft8yfRS8Ax/?ref=app

4th May 2020, 6:15 AM
un sung
un sung - avatar
2 Respostas
0
First function hi_there() will always print "hi there" no matter what argument you pass to it. Second function prints the string stored in the variable hithere. In second example, try changing res and then executing the code.
4th May 2020, 11:23 AM
Amey Bhavsar
Amey Bhavsar - avatar
0
Thank you for the feedback . However, i am having the confusion about why ? Why first always print ("hi there") but not the res="hi there ! " And why in second function Print the res="hi there!" But not print(hithere) ?
4th May 2020, 3:14 PM
un sung
un sung - avatar