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?

18th Nov 2018, 5:02 PM
thomas poku
thomas poku - avatar
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'
18th Nov 2018, 5:07 PM
Proff
Proff - avatar
+ 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.
18th Nov 2018, 5:07 PM
Ulisses Cruz
Ulisses Cruz - avatar
+ 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 :)
18th Nov 2018, 5:08 PM
Kishalaya Saha
Kishalaya Saha - avatar
+ 1
Thanks
18th Nov 2018, 5:08 PM
thomas poku
thomas poku - avatar
0
How do I declare what I is
18th Nov 2018, 5:06 PM
thomas poku
thomas poku - avatar