I have the following bit of code:
def test():
fragment = ''
fragment = raw_input('Enter input')
while fragment not in string.ascii_letters:
fragment = raw_input('Invalid character entered, try again: ')
fragment.upper()
print fragment*3
However when I run it, say for an input value of p
, fragment
gets printed as 'ppp' - all lower case, i.e. the fragment.upper()
line does not run. The same thing happens if I replace that line with string.upper(fragment)
(and adding import string at the beginning). Can someone tell me what I'm doing wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…