Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: Looping help
Post: RE: Looping help

(Jan-16-2018, 04:49 PM)buran Wrote: bottom line - because it teaches bad coding practices. As Gribouillis said, repeating code, means you need functions. They also showed relatively complex, but bet...
Wilson1218 Homework 21 9,694 Jan-16-2018, 05:07 PM
    Thread: Looping help
Post: RE: Looping help

(Jan-15-2018, 01:45 PM)buran Wrote: It is really, really bad idea to teach this to newbie students... @buran hello, I would like to ask why it is such a bad idea to teach newbies this? Is there some...
Wilson1218 Homework 21 9,694 Jan-16-2018, 04:23 PM
    Thread: Looping help
Post: RE: Looping help

(Jan-15-2018, 05:16 PM)Gribouillis Wrote: A good reflex to teach is: Repetition of code? Write a function! I knew that and do, I just didn't know how to do so for this specific scenario.
Wilson1218 Homework 21 9,694 Jan-16-2018, 07:39 AM
    Thread: Looping help
Post: RE: Looping help

(Jan-15-2018, 09:54 AM)wavic Wrote: Can you use dictionaries? per_num = {key: value for key, value in enumerate([per1, per2, per3, per4], 1)} days = {key: value for key, value in enumerate([day1, d...
Wilson1218 Homework 21 9,694 Jan-15-2018, 10:50 AM
    Thread: Looping help
Post: RE: Looping help

(Jan-15-2018, 06:57 AM)Gribouillis Wrote: If day1, day2, ... are global variables, you can do dayi = globals()['day{}'.format(i)] dayi.extend((yeild1, yeild2))Obviously, a single day list would be ...
Wilson1218 Homework 21 9,694 Jan-15-2018, 07:09 AM
    Thread: Looping help
Post: Looping help

Hello, I need help looping some code. The problem is that there are many lists that I have to .append to and they are all named similarly, but different. Can I loop this code? Note: All names of list...
Wilson1218 Homework 21 9,694 Jan-15-2018, 06:47 AM
    Thread: Pre-release practice help!
Post: RE: Pre-release practice help!

(Nov-05-2017, 12:41 PM)Lux Wrote: I think you need to declare your total_kg and rejected variables before the bag_check function, then use them globally, like this: total_kg = 0 rejected = 0 def bag...
Wilson1218 Homework 3 3,373 Nov-05-2017, 02:47 PM
    Thread: Pre-release practice help!
Post: Pre-release practice help!

Myself and a friend have been trying to do the pre-release of a previous year's iGCSE as practice. We tend to write short and simple code, rather than the 150+ line answers I've seen elsewhere. We fix...
Wilson1218 Homework 3 3,373 Nov-05-2017, 12:04 PM
    Thread: Help with faulty code.
Post: Help with faulty code.

Why won't this code work? It doesn't run through as it's meant to and fails to set the variables to what they are meant to be! The first example is "carers" being undefined when it should be 2/3. imp...
Wilson1218 General Coding Help 1 2,874 Jun-14-2017, 07:01 AM

User Panel Messages

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