FAQ  •  Login

counting words

Moderators: UncleTimmy, mjpieters

Enjoying the challenge? Need a hint?
Make a donation and help keep the site running! -thesamet
<<

sumit kumar

Posts: 4

Joined: Tue Jan 10, 2012 12:44 am

Post Wed Jan 11, 2012 2:03 am

counting words

def stringtonumber():
list=[]
print("enter the names you want")
for i in range(10):
name=raw_input(i)
list.append(name)
print("after appending list is:")
print(list)
list.sort()
print("after sorting list is")
print(list)
x=raw_input("enter the word which you want to count")
list.count(x)
i want to get user input for searching words and then count it.here is code which i m writing .so please give me the solution
<<

blast_hardcheese

Posts: 32

Joined: Wed Aug 17, 2011 12:52 am

Post Wed Jan 11, 2012 5:14 pm

Re: counting words

so please give me the solution


No. If you would like help understanding what's wrong with your code, that we can help with.

Please ask more specific questions though.

Examples of a good question:

  Code:
def stringtonumber():
    list=[]
    print("enter the names you want")
    for i in range(10):
        name=raw_input(i)
        list.append(name)
        print("after appending list is:")
        print(list)
    list.sort()
    print("after sorting list is")
    print(list)
    x=raw_input("enter the word which you want to count")
    list.count(x)


My code here prompts the user for input, building a list.
After building the list, I prompt the user for another string.
I'm trying to print the number of occurrences of that string in the list that was built before, but for some reason I don't get any output.

Any ideas why?
Help would be greatly appreciated.

Return to Suggestions

Who is online

Users browsing this forum: No registered users and 9 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.