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 Python Collections (Retired) Lists Redux Disemvoweled

William Vincent
William Vincent
779 Points

[] vs list()

Any reason in this lesson he uses [] to create a list in line 1 but list() in line 2? I "think" they're the same but somewhat confusing. He should mention if this is so in the voiceover, or which method he prefers. Otherwise () is just a tuple.

2 Answers

Kourosh Raeen
Kourosh Raeen
23,733 Points

Hi William - The parenthesis here cannot be those used for creating a tuple because they are followed by a method name, list(). To use list() you need to pass an iterable to it, as you can see in the video. So this code:

vowels = list('aeiou')

is equivalent to

vowels = ['a', 'e', 'i', 'o', 'u']
William Vincent
William Vincent
779 Points

Hi Kourosh,

Thank you for clarifying.

-William

Kourosh Raeen
Kourosh Raeen
23,733 Points

Glad I could help! Happy coding!