So I have an assignment and here are the requirements,
For this program, we'll be generating more statistics about lists. The program will work with one list that the user inputs and the other is a set list of words. The program will count how many times each of the words from the set list exists in the input list, and display these results.
Some other things to note is that I cannot use other data structures such as Python's dictionary.
Here is a rough draft of what I have so far,
def main():
setlist=['One', 'Two', 'Three']
words=input('Input words')
inputlist=getlist(words)
print(inputlist)
counts,word=comparelist(setlist,inputlist)
print(counts)
print(word)
def getlist(words):
list1=[]
count=0
for i in words.split():
j=[i,count]
count+=1
list1.append(j)
return list1
def comparelist(setlist,inputlist):
count=0
for words in setlist:
list2words=words
if list2words in inputlist:
count+=1
return count, words
else:
count=count+0
return count, words
main()
I'm still fairly new to Python, (about a few weeks practice) and I'm kinda stumped. I know it has to do with the third function but I seem to can't get it to work. Any help will be greatly appreciated.
Also, this is my first question I have asked on Stackoverflow, so any other recommendation with question etiquette would also be appreciated.
Thanks.