r/learnpython•
nyles11

Python won't print list

I am learning Python through Eric Matthes' book, "Python Crash Course".

The exercise I'm doing is telling me to print a message that includes the list I've stored in my variable. For what ever reason, everything prints but the list, which just prints the variable name rather than the list.

The code is as follows:

dead_friend = ['Malcolm X', 'Huey P. Newton', 'Marcus Garvey']

print("My good friends, " + dead_friend + ", luckily I've found a larger table and want to invite another friend!")

dead_friend.insert(0, 'Thurgood Marshall')

print("My good friends, " + dead_friend + ", luckily I've found a larger table and want to invite another friend!")

print(dead_friend)

So essentially, where dead_friend is, I want it to print my list and the error I get is: TypeError: must be str, not list

Posted Jun 26, 2017, 8:40 PM UTC

35
Loading comments…