Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
walter fernandez4,992 Points
I need help
I want to write an expression that whose value is the fifth character of the String name.
This is what I did, but It is wrong.
name = "walter." letter = name print(letter)
Brendan WhitingFront End Web Development Techdegree Graduate 84,678 Points
Array or string indices in python are 0-based. Which means the first character in the string can be found at
name. So you always have to subtract 1. The fifth character is at
name. You'll get used to it.
When you are selecting a character in a string by index, you need to start by index 0. So for example, name would give you 'w'. name would give you 'a'. So in this case, you need to subtract one from 5 to give you four. So name would give you the fifth letter of the name, which is 'e'. I hope this helps!