#!/usr/bin/env python#-*-Coding:utf-8-*-age = 3if age >= 18:print ' adult ' elif age >= 6:print ' teenager ' Else:prin T ' Kid ' print '----------------------' names = [' Jie ', ' Bob ', ' Trcy ']for name in Names:print nameprint '------------------- -----' sum = 0for x in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]:sum = sum + xprint sumprint u '-----------range (integer generation)---------------- ' Sum = 0for x in range (101): sum = sum + xprint sumprint u '------while---------------' sum = 0n = 3while n>0:sum = sum + nn = N-2sum = sum-1print sumprint u '---------input raw_input---------------' birth = Int (raw_input (' Birth: ')) #注意raw_in Put input data are characters if birth<20:print u ' 00 ago ' else:print u ' 00 after '
Note the format in which the code is saved is Utf-8
:
Indentationerror:unindent does not match no outer indentation level
This error is telling us that indentation is not right.
Print U '------while---------------'
sum = 0
n = 3
While n>0:
sum = SUM + N
n = n-2
sum = sum-1 #容易出现缩进错误, the difference between tab and space, the solution is sum = sum-1 move to the previous line, carriage return let EditPlus help us break
Print sum
Here's the interesting thing. Sum = the difference in the position of the sum-1 (before the tab, determines whether the sum = sum-1 statement belongs to while{}
Python 5 conditional judgment and looping