Posts

Showing posts with the label syntax

How to get around urllib2.HTTP when running a python script

How to get around urllib2.HTTP when running a python script I'm trying to run a python script in Windows 7 in the command prompt, however I keep receiving this error every time I try to run it. File "inb4404.py", line 73 except urllib2.HTTPError, err: ^ Syntax Error: invalid syntax I'm not sure what I'm doing wrong. I located the directory containing the python script using 'cd' and also have Python in my PATH. Then I wrote 'python inb4404.py' and received that error. Any pointers would be greatly appreciated, thank you. You're trying to run a Python 2 script in Python 3. Don't do that. – jwodder Jul 2 at 0:57 Thank you so much. That fixed the problem. – Justin Song Jul 2 at 1:16 ...

BMI with exception handling python

BMI with exception handling python I need help with this code I am trying to apply, a short time ago I ran a bmi calculator in index and now I am trying to update that code with exception handling. So far the portions don't give me errors they just run strangely together. For example, when it prompts "Enter the user's name or '0' to quit" it doesn't actually end the process it continues on to the exception process. Can someone help me write this more efficiently. here is my code this is updated, the issue I am specifically having now is the program is not terminating when the user enters '0': def bmi_calculator(): end = False print("Welcome to the BMI Calculator!") while end == False: user = input("Enter student's name or '0' to quit: ") if user == "0": print("end of report!") end = True else: print("Lets gather your information,", user) break ...