Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What are % and %s?
#2
for quiz_num in range(2):
    print("The old way,don't use it' <%s>" % quiz_num)

for quiz_num in range(2):
    print('A newer way format(),ten year old comes out with 2.6 <{}>'.format(quiz_num))

for quiz_num in range(2):
    print(f'The new way f-string 3.6 <{quiz_num}>')
Output:
The old way,don't use it' <0> The old way,don't use it' <1> A newer way format(),ten year old comes out with 2.6 <0> A newer way format(),ten year old comes out with 2.6 <1> The new way f-string 3.6 <0> The new way f-string 3.6 <1>
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