So here I have the code:
people = ['Amy','Tom','DeShawn','Catherine']
for i, f enumerate(people):
print("%r: The person's name is %s" %(i,f))
and my results are
0: The person's name is Amy
1: The person's name is Tom
2: The person's name is DeShawn
3: The person's name is Catherine
Can someone explain how does the "%r" and "%s" work in my print function. Also if any other values can be used to replace the r and s value.
The new style for formatting is using the
format()
method. Which works like this:For more info, see https://docs.python.org/3/library/string.html#string-formatting