[Tutor] Hangman game.....problem putting strings in a list.....

Peter Otten __peter__ at web.de
Tue Dec 21 11:50:29 CET 2010

Yasin Yaqoobi wrote:

> # This is the line that gives me the error don't know why?
> guessed[index] = " " + (letter); ,TypeError: 'str' object does not
> support item assignment

I don't get this far because I run into

Traceback (most recent call last):
  File "hangman.py", line 69, in <module>
    line = file.readline();
TypeError: descriptor 'readline' of 'file' object needs an argument

In the future please copy and paste the code you are actually running.

> def initArray():
>      global guessed
>      print line
       print guessed
>      guessed =  guessed[0] * (len(line)-1)
       print guessed
>      print "this is new list " + guessed;

If you add these two print statements to your code you might find out 
yourself what's going wrong.


More information about the Tutor mailing list