Bottom Page

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
Quote

Top Page

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

Forum Jump:


Users browsing this thread: 1 Guest(s)