hi, tracey,

are you allowed to use python sets? if so, you should take a look at them and 
their methods:
https://docs.python.org/3.5/tutorial/datastructures.html?highlight=data%20structures#sets

best,
james
________________________________________
From: Tutor [tutor-bounces+jderry=mail.utexas....@python.org] on behalf of 
tracey jones-Francis [drtraceyjo...@hotmail.com]
Sent: Wednesday, October 12, 2016 12:40 PM
To: tutor@python.org
Subject: [Tutor] Code for python game

Im in the middle of designing a game in python, im quite new to using it and am 
struggling with a certain bit of code. I want to have a function that will 
ignore certain words that i have specified in a dictionary. I have tried so 
many different types of code but can't seem to return just the keywords i want.


the dictionary is called skip_words and has about 20 different strings in.


so far i came up with:

def filter_words(words, skip_words):

       word = words.strip(skip_words)


       return word


The function should read an input such as help me please and filter out the 
words "please" and "me" as they are in the dictionary and just return the word 
help as the input.


>>>filter_words(["help", "me", "please"], ["me", "please"])

    ['help']


That doesn't work but i just assume it is a very simple bit of code.

any suggestions of a way that works?


Thanks:) T
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to