Quote:
|
Originally Posted by Sp32
I have never head of .shuffle or .join
|
shuffle is a function in the object
random.
random is just a class, which contains data, functions, etc. And so are
join, but it's not in the object
random, but in
str.
shuffle shuffles a list in random order, and
join puts a list into a concrete object, like a string.
Quote:
|
Originally Posted by Sp32
I have never head of .shuffle or .join and not sure what the
%s" % word
bit does
|
It's an easier way to make long messages, containing values, variables, and so on. You could have been using the +operator too, but I prefer this way. One thing you've to remember is, when there's more parameters to the string, then you have to close them in parentheses.
Code:
print "Integer: %d" % one_parameter
print "Integers: %d and %d" % (one_parameter, two_parameters)
As you see it looks better, than the following. It's also easier to handle, when you're working with bigger messages.
Code:
print "Integer: " + one_parameter
print "Integers: " + one_parameter + " and " + two_parameters