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 trialjiwon hwang
3,021 Pointshow to print out a proper .append ?
my_pets = ['Scofield', 'Edel', 'Ernie', 'Squash'] print(my_pets.append('Vera'))
numeric_collection = [1, 2, 3, 4, 5, 6] print(numeric_collection.append(54))
this is what i expected as an output: ['Scofield', 'Edel', 'Ernie', 'Squash', 'Vera']
but the result is None.
this is what i expected as an output: [1, 2, 3, 4, 5, 6, 54]
but the result is None.
2 Answers
Ave Nurme
20,907 PointsHi Jiwon
You need to append on a separate line like this:
my_pets = ['Scofield', 'Edel', 'Ernie', 'Squash']
my_pets.append('Vera')
print(my_pets)
numeric_collection = [1, 2, 3, 4, 5, 6]
numeric_collection.append(54)
print(numeric_collection)
Output for these would be:
- ['Scofield', 'Edel', 'Ernie', 'Squash', 'Vera']
- [1, 2, 3, 4, 5, 6, 54]
Hope this helps!
Ave Nurme
20,907 PointsNo reason to feel embarrassed! Happy to help out!
jiwon hwang
3,021 Pointsjiwon hwang
3,021 Pointsi feel embarrassed
thanks for your helping out