0
I understand % as modulus, but i do not understand % as used below. What is its function here:
def foo(first, second, third, *therest): print("First: %s" % first) print("Second: %s" % second) print("Third: %s" % third) print("And all the rest... %s" % list(therest)) --------------- I'm not referring to the "%s" (string), but the "% first" etc. in the code. I can't find any explanation of it in my searches
3 ответов
+ 1
here % is not modulo operator :( . it is format. (and you miss commas inside print function.)
see also
https://pyformat.info
+ 1
Thanks Yuri for your answer. The link is very helpful. This code is copied from an online course, so I cannot speak to any other errors.
+ 1
always copy- paste to Code Playground to make sure it work as expected!
(maybe, the second % works as a comma).