#Dumb question but need help understanding it

1 messages · Page 1 of 1 (latest)

molten pivot
#

I'm sorry for being dumb (always trying to get smarter) but I'm uncertain by what it means "starting index will return characters from the starting index." Am I supposed to pass colors using index?

Here is the entire instruction:

Create a new Python module in a file named “turtlecraft.py”. Add a function that, given a comma separated string of colors and a starting index, will return the characters from the starting index until the next comma or end of the string.

limber prawn
#

So it's given a string and an integer

#

Using the integer as the index, you get the characters from that index up to the next comma or end of string

molten pivot
#

so like ("green", "yellow", 5)?

#

Oh so we get characters from index?

#

For example index 0 gives you a string?

molten pivot
#

Oh wait is it assigning a integer to a string? Although not too sure about that though

limber prawn
#

("red,blue,purple,orange", 2) for example

molten pivot
#

get_color("blue,green,yellow", 0)

#

Returns blue because blue is at the 0 index?

#

As for coding it umm lemme see

#
  return "blue"
if v == 1: 
  return "red"```
#

I don't know its a rough draft

molten pivot
#

Okay I think I sort of figured it out gonna be giving updates

molten pivot
#
COLS = 16

def get_color():
  word = ("blue,green,yellow", 0)
  string = len(word)
  index = int(input("Enter a number to find the index: "))
  while string[index] == string:
    print("The character is at index: ", string)
    break 

def main():
    get_color()

main()```
#

What I have so far trying to get rid of type error since there is int and string

sturdy nacelle
#

string = len(word)
doesn't len return an int?

molten pivot
#

Okay so I think I am doing this wrong I thought I was supposed to find the index where blue is but no I was supposed to return the word blue by finding its index

molten pivot
molten pivot
#
  count = 0
  word = ("blue,green,yellow", 0)
  print("The input string is:", word)
  while count < len(word):
    print("The character is at index: ", word)
    count += 1

def main():
    get_color()

main()```
#

I think its cause I'm not iterating through the indexes of the word variable properly so it just returns the entire string

sturdy nacelle
#

remember that word is a tuple

#

so u are still not accessing the string

molten pivot
#

Now I am even more confused

molten pivot
#
  color  = "blue,green,yellow"
  start_index = 0
  if start_index == 0:
    print(color)

def main():
    get_color()

main()``` Not becoming impatient just showing my progress to get the string blue
#

Now I just have to search through the string using indexes now time for loop

#

Okay update: turns out I misunderstood the instructions again

#

Apparently I did I'm like totally lost

#

They told me there was supposed to be no loop ❓

#

Wait nvm I misread there is supposed to be a loop

slender wasp
#

i can't really help with this just wanted to say that there's nothing dumb about not understanding some concepts even if they are simple to most, your willingness to improve and put any ego aside to learn even if you believe it makes you look stupid is great and you're definitely doing the right thing, keep it going 💪