# Name: # Instructions # Remember we are still dealing with very basic programming. # The goal of this simple task is to demonstrate how to handle # Specifically, functions in general-purpose programming languages # are more flexible and expressive. This gives us more freedom than in # Microsoft Excel or other spreadsheet softwares. s1 = "At eight o'clock on Thursday morning Arthur didn't feel very good." s2 = "At five Arthur didn't feel very good." s3 = "At eight o'clock Arthur didn't feel good." s4 = "On Thursday morning Arthur didn't feel very good." sentences = [s1,s2,s3,s4] print len(s1.split()) print len(s2.split()) print len(s3.split()) print len(s4.split()) print len(s1) print len(s2) print len(s3) print len(s4) # Your Task # 1 - Use a 'for loop' to go over the list named "sentences" # 2 - Do two things in the loop: # a) print out the word count of the sentence # b) print out the length by character of the sentence # 3 - At the end, outside of the for loop, print "I'm done!" # Your codes here! for item in sentences: print item print sentences.index(item) print "I AM DONE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question