Jump to content


Check out our Community Blogs

pebz5

Member Since 27 Jun 2011
Offline Last Active Jul 16 2011 08:34 AM
-----

Posts I've Made

In Topic: Beginner Python 3.0 While Loop Issue

02 July 2011 - 10:48 AM

Hi,
This is a pretty complicated code you've put together for such a simple thing :cool:. I see that the code that I came up with was very similar to the poster before me, but I'll put it down anyways:
first_num = int(input("First number: "))
sec_num = int(input("Second number: "))

def div5(first_num, sec_num):
        for num in range(first_num, sec_num):
            if num % 5 == 0:
                return num

if abs(first_num - sec_num) <= 6:
    list_1 = sorted([first_num, div5(first_num, sec_num), sec_num])
    print(list_1)
else:          
    print("Goodbye!")
I'm a beginner myself, so I apologize for any errors, but it ran correctly for me.

In Topic: Beginner's syntax error

28 June 2011 - 05:23 AM

Thanks a lot. Yeah, I don't know why, but for some reason IDLE was marking the error in a different spot. But sure enough, when I fixed the error you saw the program loaded without any trouble. The code I wound up using went
print("You got", right, right / len(questions) * 100,
    "% right out of", index)
This seems to work. Thanks for spotting that error, I had completely overlooked it. The code's working now.

In Topic: Beginner's syntax error

27 June 2011 - 05:42 PM

Thanks for replying,
Sorry about that, I'm new. I left a comment in the code where I was hitting the problem so that anyone looking at the code would see it, but to clarify, it's towards the bottom right before the end in the section that designates what each of the options should do. It's on the line if choice == 1:. Thanks again.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download