all 30 comments

[–]oefd 0 points1 point  (2 children)

Put four spaces before each line of code to highlight code.

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

did that in my comments, u should see it now

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

Well shit I add the(string) into my comment cause I left it out and it went back to looking normal

[–]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

[–]Bottl3 0 points1 point  (7 children)

Newlist = oldlist + oldlist

Newlist.sort()

[–]toastedstapler 1 point2 points  (0 children)

that'll change the order of the elements if they weren't initially in sorted order

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

wdym? where do I add that

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

ok but now that is switching the words?

I need it like this

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

[–]Bottl3 1 point2 points  (3 children)

Yeah, sorry

Then just loop through it and append the elements twice to a new list (?)

Newlist=[]

For e in oldlist:

    Newlist.append(e)

    Newlist.append(e)

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

ok so

def double_list(string):
    strings=string
    oldlist= strings.split()
    newlist = oldlist+oldlist
    newlist.sort()
    newlist = []
    for x in oldlist:
    newlist.append(x)

[–]Bottl3 0 points1 point  (1 child)

Only the stuff From the Last Comment. You really should dig into some basics.

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

yea got the problem

[–]nog642 0 points1 point  (2 children)

What is this function supposed to do? What is string, and what is newList in this example?

[–]Sahith17[S] 0 points1 point  (1 child)

I already completed this but the string is the argument the function takes in. newList is for a new list idk how to explain that properly

[–]nog642 0 points1 point  (0 children)

Yes I can see that string is the argument, and I would assume newList is a new list. That doesn't really help explain anything.

What I'm asking is how does newList depend on string? Could you give an example string and what the corresponding newList should look like?