+ 1
Here to print dictionary %(name, number) is used, why % is used instead of common?
phonebook = {"John" : 938477566,"Jack" : 938377264,"Jill" : 947662781} for name, number in phonebook.items(): print("Phone number of %s is %d" % (name, number))
1 Antwort
+ 1
The is the C-style string interpolation. I found this article that explains it
https://www.informit.com/articles/article.aspx?p=28790&seqNum=2
This is the same as doing
print("Phone number of {} is {}".format(name, number))
And
print(f"Phone number of {name} is {number}")