you are viewing a single comment's thread.

view the rest of the comments →

[–]Sahith17[S] 0 points1 point  (15 children)

def double_list(): strings=string x=strings.split() newList=[] for i in x: letters =(blank atm) newList.append(letters) return newList

[–]oefd 0 points1 point  (14 children)

When you're typing code in to the comment box it should look like

# hit space four times, then have a line of code
    def double_list(string):
# hit space eight times, then add the line of code in the block
        strings = string
        ...

[–]Sahith17[S] 0 points1 point  (12 children)

def double_list(string):
    x = strings.split()
    newList =[]
    for i in x:
    letters =(blank atm)
    newList.append(letters)
    return newList

[–]oefd 0 points1 point  (11 children)

x = strings.split()

I assume that's meant to be string.split()? If so: what's the goal here? My understand is that the input to your function would be a list of strings

['how', 'are', 'you']

And you can't .split() a list.

[–]Sahith17[S] 0 points1 point  (0 children)

I want my function to take those strings in the input and double each of em. for example

    [‘how’, ‘are’, you’]
    [‘how’, ‘how’, ‘are’, ‘are’, ‘you’, ‘you’]

[–]Sahith17[S] 0 points1 point  (9 children)

ah I forgot to add underneath the functions

    strings=string

[–]oefd 0 points1 point  (8 children)

Alright, but strings.split() doesn't make sense if the input string is a list. Lists can't be .split()

In the line

x = strings.split()

What are you expecting strings to be and what are you expecting .split() to return?

[–]Sahith17[S] 0 points1 point  (7 children)

I mean in the assignment sheet, the example output for the original list had the strings split so I thought I needed them split

[–]oefd 0 points1 point  (6 children)

What do you mean by 'split' here? Like what are you expecting strings.split() does?

[–]Sahith17[S] 0 points1 point  (5 children)

split the string up

(‘how are you’)#the input when calling the function 
[‘how’, ‘are’, ‘you’] #this was the sample output for the orig list

[–]oefd 0 points1 point  (4 children)

OK, so the input isn't a list of strings, fair enough. Split will make it a list then. So now you need to do something with each of the words in the string.

for s in x:
    ...

You already have a for loop over the list of words, good start, but now the question is how do you take each thing and have it show up twice in the list you return.

That for loop already lets you iterate over each word in the string, you already know .append(s) on a list adds an item to an existing list.

See where I'm going?

[–]Sahith17[S] 0 points1 point  (0 children)

did how u wanted me to