Top "Python-2.7" questions

Python 2.7 is the last major version in the 2.x series, and is no longer maintained since January 1st 2020.

Iterating over dictionaries using 'for' loops

I am a bit puzzled by the following code: d = {'x': 1, 'y': 2, 'z': 3} for key in d: print key, 'corresponds …

python python-2.7 dictionary
What is the result of % in Python?

What does the % in a calculation? I can't seem to work out what it does. Does it work out a …

python python-2.7 syntax operators modulo
How to fix: "UnicodeDecodeError: 'ascii' codec can't decode byte"

as3:~/ngokevin-site# nano content/blog/20140114_test-chinese.mkd as3:~/ngokevin-site# wok Traceback (most recent call last): File "/usr/local/bin/wok", …

python python-2.7 chinese-locale
Installing PIL with pip

I am trying to install PIL (the Python Imaging Library) using the command: sudo pip install pil but I get …

python python-2.7 installation pip python-imaging-library
How can I read inputs as numbers?

Why are x and y strings instead of ints in the below code? (Note: in Python 2.x use raw_input(). …

python python-3.x python-2.7 input int
How to uninstall Python 2.7 on a Mac OS X 10.6.4?

I want to completely remove Python 2.7 from my Mac OS X 10.6.4. I managed to remove the entry from the PATH …

python macos uninstallation python-2.7
Convert list to tuple in Python

I'm trying to convert a list to a tuple. Most solutions on Google offer the following code: l = [4,5,6] tuple(l) …

python python-2.7 tuples
input() error - NameError: name '...' is not defined

I am getting an error when I try to run this simple script: input_variable = input ("Enter your name: ") print ("…

python python-2.7 input nameerror
Python 'If not' syntax

I'm a bit confused about how/why so many python developers use if not in their conditional statements. for example, …

python python-2.7
urllib and "SSL: CERTIFICATE_VERIFY_FAILED" Error

I am getting the following error: Exception in thread Thread-3: Traceback (most recent call last): File "/Library/Frameworks/Python.framework/…

python python-2.7 ssl ssl-certificate urllib