Top "Python-3.x" questions

For questions about Python programming that are specific to version 3+ of the language.

Asking the user for input until they give a valid response

I am writing a program that accepts an input from the user. #note: Python 2.7 users should use `raw_input`, the …

python validation loops python-3.x user-input
How to open a file using the open with statement

I'm looking at how to do file input and output in Python. I've written the following code to read a …

python file python-3.x file-io io
TypeError: not all arguments converted during string formatting python

The program is supposed to take in two names, and if they are the same length it should check if …

python string python-3.x typeerror output-formatting
Should I put #! (shebang) in Python scripts, and what form should it take?

Should I put the shebang in my Python scripts? In what form? #!/usr/bin/env python or #!/usr/local/bin/…

python shell python-3.x shebang
"for line in..." results in UnicodeDecodeError: 'utf-8' codec can't decode byte

Here is my code, for line in open('u.item'): #read each line whenever I run this code it gives …

python python-3.x character-encoding
Converting JSON String to Dictionary Not List

I am trying to pass in a JSON file and convert the data into a dictionary. So far, this is …

python json list python-3.x dictionary
Python NameError: name is not defined

I have a python script and I am receiving the following error: Traceback (most recent call last): File "C:\Users\…

python python-3.x nameerror
How to set Python's default version to 3.x on OS X?

I'm running Mountain Lion and the basic default Python version is 2.7. I downloaded Python 3.3 and want to set it as …

python python-3.x macos installation
Pinging servers in Python

In Python, is there a way to ping a server through ICMP and return TRUE if the server responds, or …

python python-3.x ping icmp