Try:
print str(num) + " is " + str(list.index(num))
Your problem is that you need to numbe a string in its derivation, but when indexing in the list need to intbe int. Even simpler, you can use the features of the Python function printto do the conversion for you:
print num, "is", list.index(num)
Also, do not name your lists list, which is a built-in function in Python.
source
share