Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What are % and %s?
#3
No this is not modulo. This is "string formatting" and the best way to use variable contents in a string template.
Why write it like this? So you do not do the even older way (don't use it) of combining template and variables in a completely unreadable manner like many beginners first do (because they don't know this advanced string formatting)
world = 'Poland'
today = 'Tuesday, 23. August'
print('Hello ' + world + '! How are you ' + today + '?')
Reply


Messages In This Thread
What are % and %s? - by Pedroski55 - Aug-21-2017, 10:03 AM
RE: What are % and %s? - by snippsat - Aug-21-2017, 11:03 AM
RE: What are % and %s? - by Kebap - Aug-22-2017, 09:56 AM
RE: What are % and %s? - by andre - Aug-22-2017, 10:15 AM
RE: What are % and %s? - by Kebap - Aug-22-2017, 10:41 AM
RE: What are % and %s? - by andre - Aug-22-2017, 11:48 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020