[Tutor] List issues

Danny Yoo dyoo at hashcollision.org
Thu Apr 17 19:12:03 CEST 2014


Hi Gabriel,

Try lists of non-numbers as your input, and the error should be a
little clearer to see.  You should see the conceptual error you're
making if not everything in your program is numeric.

Try:

    words = ['hello', 'world', 'hello']
    print(words.count(0))
    print(words.count('hello'))

First write down what you'd expect to see from this.  Then execute
this snippet.  Does your expectations match what you see?

---

A main bug in your program is that parts of your program are using
numbers for list indices, and other parts of your program are using
numbers as elements, but there's a little confusion in using one
notion for the other.

---

Good luck!


More information about the Tutor mailing list