Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Introducing Lists Using Lists Mutability

Magdalena Krzeszycha
Magdalena Krzeszycha
1,522 Points

Where is mistake? Cannot find one :(

video_games = [ "The Legend of Zelda: Breath of the Wild", "Splatoon 2", "Super Mario Odyssey", ]

books = [ "Automate the Boring Stuff with Python: Practical Programming for Total Beginners - Al Sweigart", "Python for Data Analysis", "Fluent Python: Clear, Concise, and Effective Programming - Luciano Ramalho", "Hello Web App: Learn How to Build a Web App - Tracy Osborn", ]

def display_list(display_name, wishes): print(display_name + ":") suggested_gift = wishes.pop(0) print("=====>", suggested_gift, "<=====") for wish in wishes: print("* " + wish) print()

display_list("Books", books) display_list("Video Games", video_games)

If the syntax of your code is your concern here, that's easy to fix:

video_games = [ "The Legend of Zelda: Breath of the Wild", 
               "Splatoon 2", 
               "Super Mario Odyssey"]

books = [ "Automate the Boring Stuff with Python: Practical Programming for Total Beginners - Al Sweigart", 
         "Python for Data Analysis", "Fluent Python: Clear, Concise, and Effective Programming - Luciano Ramalho", 
         "Hello Web App: Learn How to Build a Web App - Tracy Osborn"]

def display_list(display_name, wishes): 

    print(display_name + ":") 
    suggested_gift = wishes.pop(0)

    print("=====>", suggested_gift, "<=====") 

    for wish in wishes: 
        print("* " + wish) 
    print()

display_list("Books", books) 
display_list("Video Games", video_games)

2 Answers

Jason Boothman
Jason Boothman
6,349 Points

What error are you getting? Also...I/we can't tell from the way you have the code in (you can add code using markup), but are you sure all the new lines and indentation are correct? Python is very particular about indentation.

I just copied your code, and gave it the proper indentation and lines, and it ran for me. It should look like...

video_games = [ "The Legend of Zelda: Breath of the Wild", "Splatoon 2", "Super Mario Odyssey", ]

books = [ "Automate the Boring Stuff with Python: Practical Programming for Total Beginners - Al Sweigart", "Python for Data Analysis", "Fluent Python: Clear, Concise, and Effective Programming - Luciano Ramalho", "Hello Web App: Learn How to Build a Web App - Tracy Osborn", ]

def display_list(display_name, wishes):
    print(display_name + ":")
    suggested_gift = wishes.pop(0)
    print("=====>", suggested_gift, "<=====")
    for wish in wishes:
        print("* " + wish)
    print()

display_list("Books", books)
display_list("Video Games", video_games)
Magdalena Krzeszycha
Magdalena Krzeszycha
1,522 Points

That must have been a problem, now it works, thank you !

Jason Boothman
Jason Boothman
6,349 Points

Sure thing! I'm just going through and learning Python as well (literally just finished this one today). I love how the languages is more 'readable', but when it's using indentation/new lines instead of brackets for loops and such, you have to be very careful.