Home > Computer Programming > Today’s five-minute starter

Today’s five-minute starter

September 30, 2014 Leave a comment Go to comments

Connor’s code:

#set a variable for word count
#while a variable is true is true
#ask for a word and inform the user that they can quit
#if a word is entered
#add to the word count
#repeats the loop
#if they quit
#print out how many words they've entered
#break out of the loop

while WORD_COUNT >= 0:
  Word = raw_input("Please enter a word. Input x to quit ")
  #asks the user for an input
  if Word == "x":
    print ("You have put in %s words." % WORD_COUNT)
    #tells the user the total amount of words they've entered
    WORD_COUNT += 1 
    #adds to word count
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s