##Question
##Answer
Unless you assign the variable to be itself with a string method modifying it, then it will remain the same. Using a string method simply performs the action (upper, lower, etc.) and then moves on to the next line without changing the actual string stored in memory. For example, if you print parrot.upper( )
and then print parrot
on the next line, you’ll see it’s lowercase again! However, if we actually assign to parrot
the uppercase version of itself, it will make a change to the actual string stored in the variable: parrot = parrot.upper( )
followed by print parrot
will show you the uppercased string.
9 Likes
No, They only perform the actions be it lower
or upper
without changing the actual stored string.
The string
is permanently changed when you assign to the variable
the action be it lower
or upper
for example:
parrot = "Norwegian Blue"
parrot = parrot.upper()
print parrot
In the above example, the variable parrot
has been assigned uppercase so any string that goes in there shall be displayed in uppercase letters.
2 Likes
For the people that may want to see what’s the content of the link on this man’s profile, it does not work. He has recently activity on 2018 so he won’t answer me. I’ve helped you not waste precious seconds
wow youre right! I proved it by first coding:
1 parrot = “norwegian blue”
2 print parrot.upper()
this structure yielded me NORWEIGAN BLUE. But, when I coded in the third line print parrot, it returned to a lowercased–norweigan blue
Now, in the proceeding lines, I made it so that the string method permanently changed the string. I coded in the fourth line:
parrot= parrot.upper()
and so when I coded print parrot on the fifth line, it yielded me NORWEIGAN BLUE. I printed parrot again and again the proceeding sixth and seventh lines and it only ever yielded me an all uppercase NORWEIGAN BLUE. It did not return to lowercase since I permanently changed the string with the string method.