Python Forum
Newb question about %02d %04d
Thread Rating:
  • 2 Vote(s) - 2.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Newb question about %02d %04d
#31
(Mar-05-2019, 09:44 PM)bennylava Wrote: Particularly the part where they had me do str(row_count). What is the purpose of that?
It convert integer to string,it's used because the string is bad build up.
We use string formatting to avoid + str() and many " in one string.
In 3.6 did we get f-string,that takes over for format().
It looks a lot better like this.
def create_spreadsheet(title, row_count=1000):
      print(f"Creating a spreadsheet called {title} with {row_count} rows")

create_spreadsheet(title = "Applications", row_count=10)
Output:
Creating a spreadsheet called Applications with 10 rows
(Mar-05-2019, 09:44 PM)bennylava Wrote: Can someone go into when you can use commas, and when you can't?
Can look at is a separator between values/elements that used is many different cases.
In function over it separate function parameter title and row_count=1000
With two values it will separate automatic into a tuple.
>>> 1, 2
(1, 2)
>>> 'hello', 'world', 99
('hello', 'world', 99)
In a list a natural way to separate elements.
>>> lst = ['hello', 'car', 999]
>>> lst
['hello', 'car', 999]
>>> lst[2]
999
Reply


Messages In This Thread
Newb question about %02d %04d - by bennylava - Oct-16-2018, 03:39 AM
RE: Newb question about %02d %04d - by buran - Oct-16-2018, 06:06 AM
RE: Newb question about %02d %04d - by bennylava - Nov-06-2018, 03:46 PM
RE: Newb question about %02d %04d - by nilamo - Nov-06-2018, 03:59 PM
RE: Newb question about %02d %04d - by bennylava - Dec-11-2018, 11:01 AM
RE: Newb question about %02d %04d - by buran - Dec-11-2018, 11:14 AM
RE: Newb question about %02d %04d - by bennylava - Dec-11-2018, 12:30 PM
RE: Newb question about %02d %04d - by buran - Dec-11-2018, 01:03 PM
RE: Newb question about %02d %04d - by Gribouillis - Dec-11-2018, 01:41 PM
RE: Newb question about %02d %04d - by bennylava - Dec-15-2018, 03:25 PM
RE: Newb question about %02d %04d - by ichabod801 - Dec-15-2018, 03:45 PM
RE: Newb question about %02d %04d - by Gribouillis - Dec-15-2018, 03:47 PM
RE: Newb question about %02d %04d - by bennylava - Dec-27-2018, 07:29 PM
RE: Newb question about %02d %04d - by nilamo - Dec-27-2018, 07:45 PM
RE: Newb question about %02d %04d - by snippsat - Dec-27-2018, 09:47 PM
RE: Newb question about %02d %04d - by bennylava - Dec-30-2018, 11:06 PM
RE: Newb question about %02d %04d - by Larz60+ - Dec-31-2018, 01:28 AM
RE: Newb question about %02d %04d - by bennylava - Jan-06-2019, 01:35 PM
RE: Newb question about %02d %04d - by nilamo - Jan-07-2019, 03:50 PM
RE: Newb question about %02d %04d - by buran - Jan-06-2019, 02:10 PM
RE: Newb question about %02d %04d - by Gribouillis - Jan-06-2019, 02:14 PM
RE: Newb question about %02d %04d - by snippsat - Jan-06-2019, 02:53 PM
RE: Newb question about %02d %04d - by Gribouillis - Jan-06-2019, 02:55 PM
RE: Newb question about %02d %04d - by bennylava - Feb-12-2019, 07:26 AM
RE: Newb question about %02d %04d - by buran - Feb-12-2019, 07:53 AM
RE: Newb question about %02d %04d - by bennylava - Feb-12-2019, 11:29 AM
RE: Newb question about %02d %04d - by nilamo - Feb-12-2019, 05:00 PM
RE: Newb question about %02d %04d - by bennylava - Feb-14-2019, 05:58 AM
RE: Newb question about %02d %04d - by nilamo - Feb-14-2019, 07:14 PM
RE: Newb question about %02d %04d - by bennylava - Mar-05-2019, 09:44 PM
RE: Newb question about %02d %04d - by snippsat - Mar-05-2019, 11:23 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python newb need help Fictile 1 194 Apr-02-2024, 03:28 AM
Last Post: buran
  NameError issue with daughter's newb code MrGonk 2 1,449 Sep-16-2021, 01:29 PM
Last Post: BashBedlam
  Simple newb string question Involute 2 2,208 Sep-08-2019, 12:50 AM
Last Post: Involute
  please help this newb install pygame iofhua 7 5,925 May-15-2019, 01:09 PM
Last Post: buran
  Newb question: Debugging + Linting Python in Visual Studio Code Drone4four 1 2,423 Apr-15-2019, 06:19 AM
Last Post: perfringo
  Pthyon 3 question (newb) bennylava 11 5,846 Feb-28-2019, 06:04 PM
Last Post: buran
  newb selfie PatM 5 3,604 Feb-19-2019, 12:20 AM
Last Post: snippsat
  Complete NEWB and openpyxl project Netopia 44 17,271 Jan-18-2019, 08:15 PM
Last Post: Netopia
  Newb Question - Threading in Crons vvarrior 2 2,775 Jul-20-2018, 08:12 PM
Last Post: vvarrior
  Matt's newb question 1 MattSS102 1 2,696 Aug-28-2017, 03:27 AM
Last Post: BerlingSwe

Forum Jump:

User Panel Messages

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