We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
An example of an iterable is a list because we can keep stepping through the elements one at a time.
print instead needs multiple arguments for each object you want to print. * is a way to "unpack" a list so that it becomes arguments instead of a list. f(*[1,2,3]) converts to f(1,2,3).
Print Function
You are viewing a single comment's thread. Return to all comments →
*
ExplanationPython's Print Function defines the input as
*objects
, not asiterable
like it does for Map.An example of an iterable is a list because we can keep stepping through the elements one at a time.
print
instead needs multiple arguments for eachobject
you want to print.*
is a way to "unpack" a list so that it becomes arguments instead of a list.f(*[1,2,3])
converts tof(1,2,3)
.Example using
print
(from future in py2):The last two exhibit the desired result, you just need to set
sep=''
to get123
(w/o spaces).