## PatrickD 2 years ago Hey this is where I am... problem set 2 (1) My thought was to call a function that determined the length of the tuple -- used that information to create an empty list that would than dump the data from the tuple into the list. Call each element in the list and apply their corresponding powers. I'm thinking I need some sort of while or for statement that takes the tuple length and creates the powers. Am I on the right track? I know I could make this super simple but I assumed the point was create a polynomial function that could have a varied length... Sorry about my math vernacular.

1. Ante

You're on the right track but you're also making it a bit more complicated than it should be. "For" is a good direction and use the indexes to access tuple elements. Applying powers and accumulating the results shouldnt be hard then.

2. bwCA
3. shawnf

for i in range(len(tuple)): list[i] = tuple[i] will give you a list, but I think the only advantage here is that you can change the list values directly. there is also a one line version list = [element for i in range(len(tuple))]

4. PatrickD

On the third problem do you want to embed the function you created in the first problem?

5. PatrickD

Ok i'm still struggling with this code -- I think it's basically because I'm not writing the functions correctly. But I can't seem to add or change the list via call the locationn in the list. while guessedValue == k: print 'got here' print rangeBegin print unguessList unguessList = unguessList.insert(rangeBegin,guessedValue) print unguessList del unguessList[rangeBegin:rangeBegin] if guessedValue == k: guessCorrect = 1 else: guessCorrect = 0 All I want is for list to be checked and if it matches remove the '*" and add the called letter. There seems to be no embedded function that does this...

6. Gianko15

You don't need to do this: for i in range(len(tuple)): list[i] = tuple[i] use list = tuple [:] (clonning) You're using tuples, use them to simplify your task, take one for the letters of the word, another one with the wrong guess, and another with the good guess, using that tuples you can make a cleaner comparison; and I think that another definition about list_maker can be avoided, but it's ok anyway.

7. PatrickD

if i do that won't that just insert the entire tuple into the spot [o] on the list?

8. Gianko15

no, doing this "list = tuple [:]" will be exactly the same, and if you do list == tuple, will say True. if you do, for list[i] = tuple[i]; will look the same, but list == tuple, will say False

9. PatrickD

so i want to use (ex. list_sample = tuple_sample[:]) this will create list that is identical (for all intents and purposes to a tuple)

10. Gianko15

that's what I'm saying, clonning, why don't you try it on your Python shell so can be more familiar.

11. PatrickD

will do this should make things a bit easier :) thanks!

12. Gianko15

you're welcome!