[Tutor] ok i need some help with a for loop

Skylar Struble skylarstruble at gmail.com
Thu Oct 15 16:18:19 CEST 2009

ok so im working on a text based rpg game and am trying to get this
code to work,

items = ['crate', 'grave']
lookwords = ['look', 'examine', 'investigate','open')
input1 = raw_input('What do you want to do:')
for word in items:
    for word2 in lookwords:
         if word and word2 in input1:
            print 'you look in the crate and find a map!'
            print 'sorry you used a word i didnt understand'

it prints out all of the print things 2 times when i want it to print
1 or the other because what im trying to do is see if the input1 has
both an item from items and lookwords in the string and if so print
you look in the map or if it finds 1 or none to print sorry you used a
word i didnt understand

thanks for takeing the time to read this and gl.

More information about the Tutor mailing list