Bottom Page

Thread Rating:
  • 2 Vote(s) - 2.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Newb question about %02d %04d
(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)
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]

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Simple newb string question Involute 2 599 Sep-08-2019, 12:50 AM
Last Post: Involute
  please help this newb install pygame iofhua 7 1,575 May-15-2019, 01:09 PM
Last Post: buran
  Newb question: Debugging + Linting Python in Visual Studio Code Drone4four 1 641 Apr-15-2019, 06:19 AM
Last Post: perfringo
  Pthyon 3 question (newb) bennylava 11 1,451 Feb-28-2019, 06:04 PM
Last Post: buran
  newb selfie PatM 5 851 Feb-19-2019, 12:20 AM
Last Post: snippsat
  Complete NEWB and openpyxl project Netopia 44 5,491 Jan-18-2019, 08:15 PM
Last Post: Netopia
  Newb Question - Threading in Crons vvarrior 2 950 Jul-20-2018, 08:12 PM
Last Post: vvarrior
  Matt's newb question 1 MattSS102 1 1,174 Aug-28-2017, 03:27 AM
Last Post: BerlingSwe
  Newb: Simple Explicit Formula Duplicitous 1 1,446 May-05-2017, 07:03 PM
Last Post: buran

Forum Jump:

Users browsing this thread: 1 Guest(s)