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 Basics (2015) Python Data Types Specific Index value

Alex Ramirez
Alex Ramirez
1,885 Points

Python Basics: Challenge Task 1 of 2: I am having trouble solving this challenge.

Am I in the right direction?

index.py
var1 = "abcdef"
var1.list('f')
Tony Martin
Tony Martin
5,570 Points

Almost! The key here is to remember that counting indexes start at 0!

So, looking at your string,

  • a == [0]
  • b == [1]
  • c == [2]

.... can you figure it out from there?

1 Answer

Hello

The question not clear as I am not taking same course.

here is something that may help. Please run this code

var1 = "abcdef"

a_list = list(var1)

for a_letter in var1:

print(a_letter)

for a_letter in a_list:

print("the index is {} and the value is {}".format(a_list.index(a_letter), a_letter))

and check the print out. this should guide you

if this answers your question, please mark the question as answered.