Python Forum
How to use list to solve things
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to use list to solve things
#1
Hello! I have a problem using the list. The task is to find out how many times each word in the list appears in the list. The words are consecutive, that is, for example, an apple appears in the list three times in a row. How do I get an analysis in which two empty lists store the name in one and the number in the other?
Yoriz write Nov-13-2021, 07:23 PM:
Please post all code, output and errors (in their entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply
#2
Please post your python code and any error message. We'll be happy to help if it doesn't work as you expect.
Reply
#3
The problem is that i don't know how to even get started..
Reply
#4
Try working out the steps you would take to do it yourself not using python.
ndc85430 likes this post
Reply
#5
So something like
Start at the beginning of list, note the first word, call it active.
Move to the next word. If the same, increment a counter, otherwise call that count final and make this word the new active.
When you reach the end of the list, print out the list of words and counts.

Does that sound like what you want to do? If so, take each step and program that step. Once that is working move to the next step.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  So many things wrong, it runs but not like its supposed to kasherwood 6 2,709 Sep-26-2020, 04:57 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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