December 18th, 2012, 08:12 PM
Another Newbie ? What's the difference between %u and %s
x = "There are %d types of people." % 10
binary = "binary"
do_not = "don't"
y = "Those who know %u and those who %u." % (binary, do_not)
print "I said: %r." % x
print "I also said: '%u'." % y
hilarious = False
joke_evaluation = "Isn't that joke so funny?! %r"
print joke_evaluation % hilarious
w = "This is the left side of..."
e = "a string with a right side."
print w + e
Why when I use %u it doesn't work, but if I use %s it does work?
and I'm suppused to be using the # sign to post these post I tried that but the preview it looked like it would be hard to read for others so put it simple text
December 18th, 2012, 08:16 PM
u - the argument is treated as an integer, and presented as an unsigned decimal number.
s - the argument is treated as and presented as a string.
looks like this in the answer even though I don't understand it yet
December 19th, 2012, 12:40 PM
%u is an obsolete type – it is identical to %d for numbers
You can use %s for strings and numbers.
Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25