How do I write a code that says: "if I can do this, do this. Otherwise do nothing", in Python 2.7?
I added the code that is not working below.
words = ["glad", "lycklig", "fin", "vacker", "sot", "blomming"]
word_index = words.index("sot")
focus_word = words[word_index]
tre = words[word_index+1]
if words[word_index+2] == True:
fyra = words[word_index+2]
else:
print "the list is not long enough"
So I want to get the word that is two words after "sot" if there is one. In this case there isn't, and then I just want to skip that command.
Aucun commentaire:
Enregistrer un commentaire