0
i not defined. Meaning?
def order(sentence): number = 1 a = sentence.index(i) for number in a: return sentence[0] """elif number + 1 in sentence.index(i): return sentence.index(number + 1)""" I typed in this code but I keeping on getting i not defined. What's wrong here with the i?
5 odpowiedzi
+ 4
You havent defined i. You have defined number but the program doesnt know what do you mean by 'i', so it cannot define 'a'
+ 2
You forgot to define 'i'.
You are using it when searching the sentence:
a = sentence.index(i)
Python does not know the variable called 'i'.
If it is not supposed to be a variable but a string, put it inside quotes.
+ 2
If you want to use the character i, write sentence.index('i') instead. As it is, Python thinks i is a variable name that has not been introduced yet. Hence the error message. Hope that helps :)
+ 1
Thanks
0
How do I declare what I is