Python Forum
I need help with this please.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I need help with this please.
#1
Write a function called userWords() that repeatedly asks the user to enter words until they enter the word "stop!". Every word the user enters should be stored in a nested list arranged by word-length such that all the 3-letter words are stored in a list at index 3 (for example). Return the nested list when complete. You may assume no word is larger than 9 letters.


This is what I have so far, but it will not work.

def userWords():
    words = []
    while True:
        word = str(input("Enter a word: "))
        if word == "stop!":
            break
        else:
            words.append(word)
    print(words)
userWords()
Thanks
Reply


Messages In This Thread
I need help with this please. - by pythonlearnery - Nov-18-2018, 04:15 PM
RE: I need help with this please. - by koolinka - Nov-18-2018, 04:41 PM
RE: I need help with this please. - by ichabod801 - Nov-18-2018, 04:55 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020