Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Constructive Criticism

Name: xpoferens 2009-03-28 0:47

These tutorials make me do such basic shit, so I decided to do my own thing and copy some built in functions. Here's my first attempt at a range function. From lurking around here I've learnt that there are many ways to do the same thing, and some ways are more efficient than others. Am I doing this the complete noob way? Is there a more efficient way?

def myrange(a, b, c):
    while True:
        if b == 0:
            print('incorrect b value')
            break
        else:
            i = a
            a += b
            if abs(a) > abs(c + b):
                break
            else:
                print(i)
                continue
                print(a)
                       
       
myrange(1, 1, 10)

#Im pretty proud of my work, considering the time I have been programming, but I want to learn to be better, so any constructive criticism is welcome. If you guys want me to stop posting n00b programs tell me and I will stop.

Name: Anonymous 2009-03-28 1:10

I don't know why you're using another variable to store a. When (if abs(a) > abs(c+b)) would equal (if abs(a) > abs(c)) after the whole adding thing...

def myrange(a, b, c):
    while True:
        if b == 0:
            print('incorrect b value')
            break
        else:
            if abs(a) < abs(c):
                print(a+b)
                continue
                print(a)
            else:
                break

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List