I am a beginner to python, and I have a problem when I was trying my new program. I was trying to define a function to lowercase the inputs, but it only work with integers but int with letters, nor letters, here's what i get:
def SomeString(string):
lowcase = str(string)
lowcase.lower()
print lowcase
Only integers work, integers with letters or letters wont work:
>>> SomeString(TEST0110)
SyntaxError: invalid syntax
and
>>> SomeString(TESTString)
Traceback (most recent call last):
File "<pyshell#10>", line 1, in <module>
SomeString(TESTString)
NameError: name 'TESTString' is not defined
I tried not to use function to do this and it worked fine:
>>> String = "TEST0110"
>>> String.lower()
'test0110'
I don't know why it won't work with function, please help.
THanks.
lowcase = lowcase.lower()-- string methods return new strings. They don't modify the original string. In fact, there is no way to modify the original string. python strings are "immutable".SyntaxError. Make sure you include EVERYTHING.