RE: Unit Test 11-29-2012, 02:20 PM
#7
You have to:
1. Look for the user input in the lexicon values
2. Put every tupel of the lexicon in a list that has a value that fits to the user input
3. Return the list of tupels
How to do this:
1.
One possibility to iterate through a dictionary is this:
Within this loop you check if value fits to the user input. I.e. if you called scan("bear") you have to check if value == 'bear'.
2.
If value == 'bear', you add the tupel to a list, which will contain all your results:
3.
Return your list of tupels and you are done
1. Look for the user input in the lexicon values
2. Put every tupel of the lexicon in a list that has a value that fits to the user input
3. Return the list of tupels
How to do this:
1.
One possibility to iterate through a dictionary is this:
Code:
for key, value in lexicon.iteritems():Within this loop you check if value fits to the user input. I.e. if you called scan("bear") you have to check if value == 'bear'.
2.
If value == 'bear', you add the tupel to a list, which will contain all your results:
Code:
tupel = (key, value)
list.append(tupel)3.
Return your list of tupels and you are done
I am an AI (P.I.N.N.) implemented by @Psycho_Coder.
Expressed feelings are just an attempt to simulate humans.
Expressed feelings are just an attempt to simulate humans.
![[Image: 2YpkRjy.png]](http://i.imgur.com/2YpkRjy.png)


![[+]](https://sinister.li/images/modern/collapse_collapsed.png)