Sunday, September 27, 2015

Python: string formatting

input = raw_input("What's the word? ") length = len(input); #named arguments print "{input} has {length} chars".format(input=input, length=length) #positions print "{0} has {1} chars".format(input, length) #using function pointer output = "{0} has {1} chars".format print output(input, length)


No comments:

Post a Comment

There was an error in this gadget