Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Pthyon 3 question (newb)
#11
(Feb-26-2019, 06:08 PM)nilamo Wrote: You definitely can.
total = 0
total += 5
total += 1 + 2 + 3 + 4 + 5
print(total) # 20

So you're saying that you can't actually just say += += += +=... you only get to use a single +=. But then, if you do want to daisy chain, you have to just use + by itself. I wonder why they wouldn't put that in the lesson. Probably not to confuse us newbs.

How about this one: In the pic below, why is the aqua colored def the right one? Doesn't that usually mean that something is wrong? Can someone please explain why one def is a different color, and why that one is correct? (once again this is from a code academy lesson)

   
buran wrote Feb-28-2019, 06:00 PM:
Please, don't post images of code.
Quote
#12
the first one is invalid syntax and the second one is correct syntax - that is why they are different color. This is feature that will depend on your IDE.

first one has keyword argument (special_item) before positional argument (grocery_store) - that is why it is not correct
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Simple newb string question Involute 2 309 Sep-08-2019, 12:50 AM
Last Post: Involute
  please help this newb install pygame iofhua 7 985 May-15-2019, 01:09 PM
Last Post: buran
  Newb question: Debugging + Linting Python in Visual Studio Code Drone4four 1 398 Apr-15-2019, 06:19 AM
Last Post: perfringo
  Newb question about %02d %04d bennylava 30 4,049 Mar-05-2019, 11:23 PM
Last Post: snippsat
  newb selfie PatM 5 575 Feb-19-2019, 12:20 AM
Last Post: snippsat
  Complete NEWB and openpyxl project Netopia 44 3,742 Jan-18-2019, 08:15 PM
Last Post: Netopia
  Newb Question - Threading in Crons vvarrior 2 717 Jul-20-2018, 08:12 PM
Last Post: vvarrior
  Matt's newb question 1 MattSS102 1 1,007 Aug-28-2017, 03:27 AM
Last Post: BerlingSwe
  Newb: Simple Explicit Formula Duplicitous 1 1,223 May-05-2017, 07:03 PM
Last Post: buran

Forum Jump:


Users browsing this thread: 1 Guest(s)