Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: Python returns generator instead of None
Post: RE: Python returns generator instead of None

(Mar-08-2018, 10:44 PM)Gribouillis Wrote: Every function containing the yield keyword is a generator. I see, then is there any way to simply return "None" instead of a generator?
Tawnwen General Coding Help 4 4,639 Mar-08-2018, 11:11 PM
    Thread: Python returns generator instead of None
Post: Python returns generator instead of None

I have no clue why this is occurring. My class function isn't returning None regardless of how I write my code. Here's my search function below: def search(self, box): if len(self.truck.b...
Tawnwen General Coding Help 4 4,639 Mar-08-2018, 10:33 PM
    Thread: Linear Fibonacci sequence
Post: Linear Fibonacci sequence

Currently learning Python recursion and stuck on how to write linear-time fib function: def goodfib(k): if k == 0: return 0, 0, 1 if k == 1: return 1, 0, 1 u = goodfib(k - 1) ### fill...
Tawnwen Homework 1 3,265 Feb-27-2018, 06:05 AM
    Thread: How to fix UnboundLocalError
Post: RE: How to fix UnboundLocalError

(Jan-07-2018, 08:08 AM)Gribouillis Wrote: It is good practice to avoid global statements in python code, because they obfuscate the code somewhat, but they are allowed. Thanks! That fixed it. No ne...
Tawnwen General Coding Help 5 5,272 Jan-07-2018, 04:16 PM
    Thread: How to fix UnboundLocalError
Post: How to fix UnboundLocalError

The code below models a simple game that tests if an input occurs in the list. The function is called twice, then the total # of correct answers is printed. foot_bones = ["calcaneus", "talus", "cuboi...
Tawnwen General Coding Help 5 5,272 Jan-07-2018, 05:59 AM
    Thread: Help with a function?
Post: RE: Help with a function?

I knew it was a silly error, thank you.
Tawnwen General Coding Help 2 2,408 Jan-06-2018, 04:11 AM
    Thread: Help with a function?
Post: Help with a function?

Hello, I'm very new to Python (and coding overall) and am taking my first course. Currently writing a function that takes a letter, space, or empty string as a parameter and returns the number in whi...
Tawnwen General Coding Help 2 2,408 Jan-06-2018, 03:46 AM

User Panel Messages

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