now I've this runtime error:
TypeError: 'int' object is not iterable
Name:
Anonymous2010-05-19 6:27
>>3
Go ask you're homework questions somewhere else.
Name:
Anonymous2010-05-19 6:34
>>4
Am I supposed to feel bad for asking a /prog/ related question in /prog/? No doubt I'm new to the language and programming in general. If you'd like me to leave quickly/improve my skills, you'd answer the question. Anything less is an act of trolling. Why post on a /prog/ if you've no intention of discussing /prog/ related material? Perhaps you're incapable of debugging a program so simple?
do the "[]" ask it to search the list for the value inside the "[]"?
No, what are you learning python from, because they are filling your mind with bullshit.
When you use the command a[x], you are telling python to get the value stored in the 'a' list at position 'x'.
if so, wouldn't "(index)" be the correct way to call the element of the list?
no, if you are determined to do it with a list method, use a.index(x)
Seriously though, google yourself up a couple of python tutorials and learn the language.
Name:
Anonymous2010-05-19 7:38
>>10
Thank you for the information. I doubt it's the book. Rather, I'm not paying close enough attention. I believe I've figured it out.
new_list += a(i) + b(i):
is incorrect because I was asking for the element of a tuple instead of a list.
new_list += a[i] + b[i]:
is incorrect because I was attempting to concatenate an integer to a list. ie: "[] + int"
new_list += [a[i] + b[i]]:
corrects the above because it concatenates a list instead of an integer.
Once again thank you for the help. I appreciate it.
I'll continue plucking through this book and will work at reading and debugging more carefully.
>>11 is incorrect because I was asking for the element of a tuple instead of a list.
No. Tuples are accessed in the same way as lists. What you were doing was trying to call those lists as if they were functions, with the argument i. Read your fucking error messages.
Also: add_lists = lambda a, b: reduce(lambda n, (a, b): n + [a + b], zip(a, b), [])
>>15That's the point if __name__ == '__main__': FIOC MY ANUS
Name:
Anonymous2010-05-19 17:55
>>16 if __name__ == '__main__':
Can someone explain wtf this is about?
I have a misbehaving script with this particular test (which seems to be failing.) I'm not an FIOC programmer so it's not clear to me what this is about.
>>17
It means that the code will only be executed if you run that file directly (i.e. as "__main__"), but won't run if you use that file as a library. It's useful for tests.