Re: [Tutor] Help understanding list comprehensions

2015-06-18 Thread Laura Creighton
In a message of Thu, 18 Jun 2015 04:40:05 -, Anubhav Yadav writes: >So I need to create a copy of the list before trying to iterate through the >list. >Thanks a lot everyone for their answers. Er, I think you understand, but what you need to do is to make a copy of the list, and _interate thro

Re: [Tutor] Help understanding list comprehensions

2015-06-18 Thread Alan Gauld
On 18/06/15 05:40, Anubhav Yadav wrote: So I need to create a copy of the list before trying to iterate through the list. Only if you are going to change it. The problem you had was that you were removing items from the thing you were iterating over. As a result the other items effectively move

Re: [Tutor] Help understanding list comprehensions

2015-06-18 Thread Anubhav Yadav
So I need to create a copy of the list before trying to iterate through the list. Thanks a lot everyone for their answers. Cheers. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/list

Re: [Tutor] Help understanding list comprehensions

2015-06-17 Thread Alan Gauld
On 17/06/15 09:58, Anubhav Yadav wrote: I understand that my title was a little misleading, and I apologise for the same. Here is code that worked: marks = [] for i in range(int(input())): Don't use input(). Use raw_input() instead. You almost never want input() in python 2. name = raw

Re: [Tutor] Help understanding list comprehensions

2015-06-17 Thread Laura Creighton
In a message of Wed, 17 Jun 2015 14:28:54 +0530, Anubhav Yadav writes: >Either the subject is misleading or you misunderstand something. Im am >sorry to tell you the great truth, but there was no list comprehension in >your code at all, just a list. Comprehension is what Alan wrote for you, >that

Re: [Tutor] Help understanding list comprehensions

2015-06-17 Thread Anubhav Yadav
Either the subject is misleading or you misunderstand something. Im am sorry to tell you the great truth, but there was no list comprehension in your code at all, just a list. Comprehension is what Alan wrote for you, that is the next step in studying Python, when you already understand lists and

Re: [Tutor] Help understanding list comprehensions

2015-06-17 Thread Válas Péter
Either the subject is misleading or you misunderstand something. Im am sorry to tell you the great truth, but there was no list comprehension in your code at all, just a list. Comprehension is what Alan wrote for you, that is the next step in studying Python, when you already understand lists and

Re: [Tutor] Help understanding list comprehensions

2015-06-16 Thread Anubhav Yadav
I am sorry I didn't posted my code. I had solved this question long back on hackerrank, and I couldn't figure out why this behaviour was seen in this problem, so I had posted this question on their discussion forum. Couldn't get a good answer so I decided to post here. Luckily I found the revision

Re: [Tutor] Help understanding list comprehensions

2015-06-16 Thread Alan Gauld
On 16/06/15 20:39, Anubhav Yadav wrote: I am sorry I didn't posted my code. I had solved this question long back on hackerrank, and I couldn't figure out why this behaviour was seen in this problem, so I had posted this question on their discussion forum. Couldn't get a good answer so I decided

Re: [Tutor] Help understanding list comprehensions

2015-06-16 Thread Válas Péter
What is the exact meaning of "marks" and "lowest" in your script? Where are they defined?0 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Help understanding list comprehensions

2015-06-16 Thread Alan Gauld
On 16/06/15 16:45, Anubhav Yadav wrote: I have a doubt. So have I. I can't se your code so I don't know what's happening. Don't make us guess, show us the code. I had a list like this [['Varun', 19.0], ['Kakunami', 19.0], ['Harsh', 20.0], ['Beria', 20.0], ['Vikas', 21.0]] But its not assig

[Tutor] Help understanding list comprehensions

2015-06-16 Thread Anubhav Yadav
I have a doubt. I had a list like this [['Varun', 19.0], ['Kakunami', 19.0], ['Harsh', 20.0], ['Beria', 20.0], ['Vikas', 21.0]] I am using a for loop to del the rows with the lowest value like this: for row in marks: if row[1] == lowest: marks.remove(row) But after running this loo