Precautions when dealing with control structures in Python 2.6

For those who use Python 2.6. In 2.6, the following code will result in an error.

for i in range(10):
  if(i%2 == 0):
      print("{} is even".format(i))
  else:
      print("{} is odd".format(i))
print("done")

2.6 doesn't seem to work with the above writing style. http://stackoverflow.com/questions/10054122/valueerror-zero-length-field-name-in-format-python

for i in range(10):
  if(i%2 == 0):
      print("{0} is even\n".format(i))
  else:
      print("{0} is odd\n".format(i))
print("done")

If so, it works.

We recommend using 2.7 or 3 series.

Recommended Posts

Precautions when dealing with control structures in Python 2.6
Precautions when dealing with ROS MultiArray types in Python
Character encoding when dealing with files in Python 3
Japanese output when dealing with python in visual studio
Precautions when using pit in Python
Until dealing with python in Atom
Precautions when using six with Python 2.5
Precautions when pickling a function in python
Tips for dealing with binaries in Python
Precautions when solving DP problems with Python
Dealing with "years and months" in Python
How to not escape Japanese when dealing with json in python
gRPC-Methods used when dealing with protocol buffers types in Python CopyFrom, Extend
[Python] Dealing with multiple call errors in ray.init
[Web development with Python] Precautions when saving cookies
Mailbox selection when retrieving Gmail with imaplib in python
Scraping with selenium in Python
Scraping with chromedriver in python
Debugging with pdb in Python
Working with sounds in Python
Scraping with Selenium in Python
Scraping with Tor in Python
Tweet with image in Python
Attention when os.mkdir in Python
Combined with permutations in Python
Error when playing with python
Problem not knowing parameters when dealing with Blender from Python
Things to keep in mind when using Python with AtCoder
Things to keep in mind when using cgi with python.
Number recognition in images with Python
Testing with random numbers in Python
GOTO in Python with Sublime Text 3
Working with LibreOffice in Python: import
Scraping with Selenium in Python (Basic)
Behavior when listing in Python heapq
CSS parsing with cssutils in Python
Precautions when installing tensorflow with anaconda
Numer0n with items made in Python
Open UTF-8 with BOM in Python
Use rospy with virtualenv in Python3
Python data structures learned with chemoinformatics
Use Python in pyenv with NeoVim
Heatmap with Dendrogram in Python + matplotlib
Read files in parallel with Python
Precautions when creating a Python generator
Password generation in texto with python
Try frequency control simulation with Python
Use OpenCV with Python 3 in Window
Precautions when using phantomjs from python
When matplotlib doesn't work with python2.7
When using MeCab with virtualenv python
Get started with Python in Blender
When using regular expressions in Python
When writing a program in Python
Working with DICOM images in Python
[Python] Format when to_csv with pandas
Precautions when passing def to sorted and groupby functions in Python? ??
Precautions when giving default values to arguments in Python function definitions
Here's a summary of things that might be useful when dealing with complex numbers in Python
When specifying multiple keys in python sort
Spiral book in Python! Python with a spiral book! (Chapter 14 ~)