Back

Python Chrestomathics

Ahead


 

Part 8 — Looping

We are humankind — What a mantra that should be — I’m human and kind

Did you not expect – The repetition to come – Did you not expect

magnifying glass parchment parchment

Section 8.1: Why it’s necessary


Section 8.2: For loop — first contact

reply = input( "Enter text: " )

words = reply.split()

Enter text: eat a peach

reply: eat a peach

words: ['eat', 'a', 'peach']

# print the characters in the reply one by one

print( "reply: character by character" )

for character in reply :

  print( character )

print()

  print( character )

reply: character by character

e

a

t

 

a

 

p

e

a

c

h

 

words: word by word

eat

a

peach

print( "reply:", reply )

print( "words:", words )


8.X What’s next

 


© Jim Cohoon. For now, all rights reserved.