Re: [Tutor] List vs. Set:

2018-02-25 Thread Steven D'Aprano
On Sat, Feb 24, 2018 at 08:00:58PM +, James Lundy wrote: > Could this be a bug in my Pycharm 3 compiler I have had mixed > experiences running the code. As a general rule, any time you get an unexpected error and think "Could this be a bug in the compiler?", the chances are almost always

Re: [Tutor] List vs. Set:

2018-02-25 Thread Mark Lawrence
On 24/02/18 20:00, James Lundy wrote: To whom it may concern. This code is from Dr. John Keyser. Please arrange for him to go on a programming course :-) gooddata = [] for singleday in datalist: if (singleday[0] == day) and (singleday[1] == month): Yuck, unneeded brackets disease.

Re: [Tutor] List vs. Set:

2018-02-25 Thread Alan Gauld via Tutor
On 24/02/18 20:00, James Lundy wrote: > To whom it may concern. This code is from Dr. John Keyser. Since you don;t show us the complete program I will have to make some assumptions... > gooddata = [] This is degioned as a list by virtue of the [] > for singleday in datalist: > if

[Tutor] List vs. Set:

2018-02-25 Thread James Lundy
To whom it may concern. This code is from Dr. John Keyser. gooddata = [] for singleday in datalist: if (singleday[0] == day) and (singleday[1] == month): gooddata.append({singleday[2], singleday[3], singleday[4], singleday[5]}) # Perform analysis minsofar = 120 maxsofar = -100

[Tutor] list of functions

2017-03-30 Thread kay Cee
Greetings all, I would like to use a list of functions for an automation project, and this is the prototype I came up with ### def func1(): print('func1') def func2(): print('func2') def func3(): print('func3') func_list = ('func1', 'func2', 'func3') for f in

[Tutor] Testing tutor list server

2016-09-20 Thread Alan Gauld via Tutor
Just checkin' -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To

Re: [Tutor] META: Moderation and subscription to the tutor list

2016-05-08 Thread Alan Gauld via Tutor
On 08/05/16 08:59, Alan Gauld via Tutor wrote: > This means you can get > - single emails (default) > - emails plus digest - digest and no emails > - neither (this is my choice because I read via gmane) Sorry, I missed an option... -- Alan G Author of the Learn to Program web site

Re: [Tutor] META: Moderation and subscription to the tutor list

2016-05-08 Thread Steven D'Aprano
On Sun, May 08, 2016 at 08:59:01AM +0100, Alan Gauld via Tutor wrote: > On 01/05/16 05:18, Steven D'Aprano wrote: > > > ...(And I think we should default to > > individual emails, not daily digest.) > > It took me a little while to find this one, but I've checked > and the default is to receive

Re: [Tutor] META: Moderation and subscription to the tutor list

2016-05-08 Thread Alan Gauld via Tutor
On 01/05/16 05:18, Steven D'Aprano wrote: > ...(And I think we should default to > individual emails, not daily digest.) It took me a little while to find this one, but I've checked and the default is to receive individual emails. You need to opt-in to get the digests and opt-out to stop

Re: [Tutor] "List" object is not callable

2016-05-01 Thread Jason N. via Tutor
Hello, I figured out the issue. It was a silly mistake - i was not running the correct code; instead was running code from another program which was active on a second tab. Thank you. On Sunday, May 1, 2016 4:15 PM, Jason N. via Tutor wrote: Thank you all for your

Re: [Tutor] "List" object is not callable

2016-05-01 Thread Jason N. via Tutor
Thank you all for your responses.  I am using Py 2.7 and this time I copied and pasted the code from here: http://www.opentechguides.com/how-to/article/python/57/python-ping-subnet.html  to my system but received the same error when I ran it.  You can see the error screenshot here: 

Re: [Tutor] META: Moderation and subscription to the tutor list

2016-05-01 Thread Alan Gauld via Tutor
On 01/05/16 07:23, boB Stepp wrote: > I am in agreement with this as well. I have often wondered if > newcomers are subscribed or not Most are. Several who are not, subscribe very soon after - presumably in response to the intro message. > as after subscription one receives a > very helpful

Re: [Tutor] META: Moderation and subscription to the tutor list

2016-05-01 Thread Alan Gauld via Tutor
On 01/05/16 10:06, Alan Gauld via Tutor wrote: > Quite a lot of people use the digest service, especially lurkers. > (A quick scan of the members lists suggests around 35-40% > of all members use digest). I'd be reluctant to remove a > service that is so widely used. I've just had a look at the

Re: [Tutor] META: Moderation and subscription to the tutor list

2016-05-01 Thread Alan Gauld via Tutor
On 01/05/16 06:35, c...@zip.com.au wrote: > There seems to me a subjectly large number of very short threads with a > question from someone, a couple of responses from list members, and no > further > reply. > > To me this argues that either newcomers are not subscribed and probably do > not

Re: [Tutor] META: Moderation and subscription to the tutor list

2016-05-01 Thread Alan Gauld via Tutor
On 01/05/16 05:18, Steven D'Aprano wrote: > What's your policy here on the tutor list? I don't really have a policy. The list policy, set by my predecessors, is to allow anyone to send mail and encourage them to subscribe. All unsubscribed mail goes to moderation (and there is not very m

Re: [Tutor] META: Moderation and subscription to the tutor list

2016-05-01 Thread boB Stepp
f >> seeing the replies. >> >> Of course, in the case of python-list, non-subscribers can just use the >> Usenet interface (comp.lang.python, or Google Groups, or gmane). But >> anyone using Usenet is presumably savvy enough to check for replies >> using Usenet.

Re: [Tutor] META: Moderation and subscription to the tutor list

2016-05-01 Thread cs
ane). But anyone using Usenet is presumably savvy enough to check for replies using Usenet. What's your policy here on the tutor list? I think we should require subscription before people can post. (And I think we should default to individual emails, not daily digest.) I am not Alan, but pers

[Tutor] META: Moderation and subscription to the tutor list

2016-04-30 Thread Steven D'Aprano
or replies using Usenet. What's your policy here on the tutor list? I think we should require subscription before people can post. (And I think we should default to individual emails, not daily digest.) -- Steve ___ Tutor maillist - Tutor@

Re: [Tutor] "List" object is not callable

2016-04-30 Thread Steven D'Aprano
On Sat, Apr 30, 2016 at 06:51:17PM +, Jason N. via Tutor wrote: > Hello, > I found this simple script online but when I execute it I get the > following error: "TypeError: 'list' object is not callable" Here is > the code sample: > > import subprocess > ls_output=

Re: [Tutor] "List" object is not callable

2016-04-30 Thread bob gailer
On 4/30/2016 3:27 PM, Alex Kleider wrote: On 2016-04-30 11:51, Jason N. via Tutor wrote: Hello, I found this simple script online but when I execute it I get the following error: "TypeError: 'list' object is not callable" Here is the code sample:import subprocess ls_output=

Re: [Tutor] "List" object is not callable

2016-04-30 Thread Alex Kleider
On 2016-04-30 11:51, Jason N. via Tutor wrote: Hello, I found this simple script online but when I execute it I get the following error: "TypeError: 'list' object is not callable" Here is the code sample:import subprocess ls_output= subprocess.check_output(['dir']) It works on my system:

[Tutor] "List" object is not callable

2016-04-30 Thread Jason N. via Tutor
Hello, I found this simple script online but when I execute it I get the following error: "TypeError: 'list' object is not callable" Here is the code sample:import subprocess ls_output= subprocess.check_output(['dir']) I searched online and found a another similar code sample

Re: [Tutor] List of tuples

2016-04-20 Thread Alan Gauld via Tutor
On 19/04/16 21:56, isaac tetteh wrote: > I have a list like this > [ > ("name",2344,34, "boy"),("another",345,47,"boy", "last") > ] Assuming this is list_tuple... > for row in list_tuple: > for row2 in row: > return row This can't work because return needs to be inside a function.

Re: [Tutor] List of tuples

2016-04-20 Thread isaac tetteh
) * (3 - len(rv))ValueError: too many values to unpack > From: d...@hashcollision.org > Date: Tue, 19 Apr 2016 15:01:41 -0700 > Subject: Re: [Tutor] List of tuples > To: itette...@hotmail.com > CC: tutor@python.org > > On Tue, Apr 19, 2016 at 1:56 PM, isaac tetteh &l

Re: [Tutor] List of tuples

2016-04-19 Thread Danny Yoo
Sorry for typos in response: on cell phone at the moment. ;p ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] List of tuples

2016-04-19 Thread Danny Yoo
Okay, in the context of a function, the error you're seeing makes more sense. You need to ensure that the return value of the function is of the right type. In SingleView, the intended return value appears to be a structured response value. Given that, then any other return statements in the

Re: [Tutor] List of tuples

2016-04-19 Thread Danny Yoo
On Tue, Apr 19, 2016 at 1:56 PM, isaac tetteh wrote: > I have a list like this > [ > ("name",2344,34, "boy"),("another",345,47,"boy", "last") > ] > How do u get each value from it like > Output > name > 2344 > 34 > ... > > What i did was > for row in list_tuple: > for

[Tutor] List of tuples

2016-04-19 Thread isaac tetteh
I have a list like this [ ("name",2344,34, "boy"),("another",345,47,"boy", "last") ] How do u get each value from it like Output name 2344 34 ... What i did was for row in list_tuple: for row2 in row: return row But i get error too many value to unpack Please help Sent from

Re: [Tutor] my membership and access to the Tutor list

2015-05-12 Thread Alan Gauld
? *From:* Alan Gauld alan.ga...@btinternet.com *To:* Stewart Lawton jstewartlaw...@yahoo.co.uk; tutor tutor@python.org *Sent:* Friday, 8 May 2015, 10:33 *Subject:* Re: my membership and access to the Tutor list On 08/05/15 09:09, Stewart

Re: [Tutor] my membership and access to the Tutor list

2015-05-08 Thread Alan Gauld
On 08/05/15 09:09, Stewart Lawton wrote: Hi Alan Thank you very much for your response to my Tutor@python.org question. I thought my membership was complete and that I could log in to answer your comments. The tutor list is a mailing list not a web forum. You don't login to answer comments

Re: [Tutor] list semantics

2015-04-11 Thread Joel Goldstick
On Sat, Apr 11, 2015 at 1:41 PM, Jim Mooney cybervigila...@gmail.com wrote: Why does the first range convert to a list, but not the second? p = list(range(1,20)), (range(40,59)) p ([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], range(40, 59)) Assuming you are using

Re: [Tutor] list semantics

2015-04-11 Thread Joel Goldstick
On Sat, Apr 11, 2015 at 3:21 PM, Steven D'Aprano st...@pearwood.info wrote: On Sun, Apr 12, 2015 at 05:09:43AM +1000, Steven D'Aprano wrote: Almost correct, but not quite. range, like xrange in Python 2, is not a generator, but a custom-made lazy sequence object. py gen() # This actually is

Re: [Tutor] list semantics

2015-04-11 Thread Timo
Op 11-04-15 om 19:41 schreef Jim Mooney: Why does the first range convert to a list, but not the second? p = list(range(1,20)), (range(40,59)) p ([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], range(40, 59)) I'm not sure I understand correctly. This is what the top

Re: [Tutor] list semantics

2015-04-11 Thread Steven D'Aprano
On Sat, Apr 11, 2015 at 10:41:28AM -0700, Jim Mooney wrote: Why does the first range convert to a list, but not the second? p = list(range(1,20)), (range(40,59)) p ([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], range(40, 59)) Why would the second convert to a

Re: [Tutor] list semantics

2015-04-11 Thread Steven D'Aprano
On Sun, Apr 12, 2015 at 05:09:43AM +1000, Steven D'Aprano wrote: Almost correct, but not quite. range, like xrange in Python 2, is not a generator, but a custom-made lazy sequence object. py gen() # This actually is a generator. generator object gen at 0xb7bd7914 py range(1, 10) # This

[Tutor] list semantics

2015-04-11 Thread Jim Mooney
Why does the first range convert to a list, but not the second? p = list(range(1,20)), (range(40,59)) p ([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], range(40, 59)) -- Jim Stop, Harold! That bagel has radishes! Thank God, Mary - you've saved me again!

Re: [Tutor] List comprehensions to search a list--amazing!

2015-03-23 Thread boB Stepp
On Thu, Mar 19, 2015 at 4:52 AM, Peter Otten __pete...@web.de wrote: Dave Angel wrote: [...] By the way, if you were to use a plain old loop the expected speedup over the listcomp would be 2. You can break out of the loop when you have found the gap, after iterating over one half of the list

Re: [Tutor] List comprehensions to search a list--amazing!

2015-03-23 Thread Dave Angel
On 03/23/2015 10:17 PM, Dave Angel wrote: On 03/23/2015 09:42 PM, boB Stepp wrote: Not really. See Steve's OOPS. Peter's response for some numbers. If I had to guess, I'd say that for lists over 100 items, you should use bisect or equivalent. But I'd also say you should have one

Re: [Tutor] List comprehensions to search a list--amazing!

2015-03-23 Thread Steven D'Aprano
On Mon, Mar 23, 2015 at 08:42:23PM -0500, boB Stepp wrote: On Thu, Mar 19, 2015 at 12:10 AM, Dave Angel da...@davea.name wrote: The catch to a list comprehension is it has to visit all the elements, while a binary search would visit log-base-2 of them. So instead of 1 elements, you'd

Re: [Tutor] List comprehensions to search a list--amazing!

2015-03-23 Thread boB Stepp
On Thu, Mar 19, 2015 at 12:10 AM, Dave Angel da...@davea.name wrote: The catch to a list comprehension is it has to visit all the elements, while a binary search would visit log-base-2 of them. So instead of 1 elements, you'd be searching about 14 items. I suspected as much, but had not

Re: [Tutor] List comprehensions to search a list--amazing!

2015-03-23 Thread Dave Angel
On 03/23/2015 09:42 PM, boB Stepp wrote: On Thu, Mar 19, 2015 at 12:10 AM, Dave Angel da...@davea.name wrote: The catch to a list comprehension is it has to visit all the elements, while a binary search would visit log-base-2 of them. So instead of 1 elements, you'd be searching about 14

Re: [Tutor] List comprehensions to search a list--amazing!

2015-03-23 Thread Steven D'Aprano
On Mon, Mar 23, 2015 at 10:17:11PM -0400, Dave Angel wrote: On 03/23/2015 09:42 PM, boB Stepp wrote: Can you give me a ballpark number for large, where this would start making a meaningful difference? Not really. See Steve's response for some numbers. o_O Have you borrowed Guido's Time

Re: [Tutor] List comprehensions to search a list--amazing!

2015-03-20 Thread Peter Otten
Patrick Thunstrom wrote: The generalized problem: L = [V0, V1, ..., Vn], where V0 = V1 = V2 = ... = Vn . Find index i, such that V[i] = Vt = V[i + 1], where Vt is the test value being searched for. I need to know the indices i and i + 1, which I need to interpolate based on where Vt falls.

Re: [Tutor] List comprehensions to search a list--amazing!

2015-03-19 Thread Peter Otten
Dave Angel wrote: On 03/19/2015 12:20 AM, boB Stepp wrote: I hope extolling the beauty and power of Python on this list is allowed, because I have had a large WOW!!! moment tonight. I had a problem I was working on at work this afternoon. I have a list of ~ 10,000 floating point numbers,

Re: [Tutor] List comprehensions to search a list--amazing!

2015-03-19 Thread Patrick Thunstrom
The generalized problem: L = [V0, V1, ..., Vn], where V0 = V1 = V2 = ... = Vn . Find index i, such that V[i] = Vt = V[i + 1], where Vt is the test value being searched for. I need to know the indices i and i + 1, which I need to interpolate based on where Vt falls. The solution (As a

Re: [Tutor] List comprehensions to search a list--amazing!

2015-03-18 Thread Mark Lawrence
On 19/03/2015 04:20, boB Stepp wrote: I hope extolling the beauty and power of Python on this list is allowed, because I have had a large WOW!!! moment tonight. I had a problem I was working on at work this afternoon. I have a list of ~ 10,000 floating point numbers, which run from largest to

[Tutor] List comprehensions to search a list--amazing!

2015-03-18 Thread boB Stepp
I hope extolling the beauty and power of Python on this list is allowed, because I have had a large WOW!!! moment tonight. I had a problem I was working on at work this afternoon. I have a list of ~ 10,000 floating point numbers, which run from largest to smallest. There are duplicates scattered

Re: [Tutor] List comprehensions to search a list--amazing!

2015-03-18 Thread Dave Angel
On 03/19/2015 12:20 AM, boB Stepp wrote: I hope extolling the beauty and power of Python on this list is allowed, because I have had a large WOW!!! moment tonight. I had a problem I was working on at work this afternoon. I have a list of ~ 10,000 floating point numbers, which run from largest to

Re: [Tutor] List of ints

2015-03-04 Thread Albert-Jan Roskam
- Original Message - From: Mark Lawrence breamore...@yahoo.co.uk To: tutor@python.org Cc: Sent: Wednesday, March 4, 2015 10:20 AM Subject: Re: [Tutor] List of ints On 04/03/2015 00:25, Steven D'Aprano wrote: On Tue, Mar 03, 2015 at 04:50:41PM +1000, Phil wrote: count [0

Re: [Tutor] List of ints

2015-03-04 Thread Alan Gauld
On 03/03/15 23:44, Mark Lawrence wrote: Having never heard of QPython I've just looked it up, so for those who don't know from http://qpython.com/ it's a script engine which runs Python programs on android devices. I doubt if there is much experience on this list with it although you might get

Re: [Tutor] List of ints

2015-03-04 Thread Mark Lawrence
On 04/03/2015 00:25, Steven D'Aprano wrote: On Tue, Mar 03, 2015 at 04:50:41PM +1000, Phil wrote: count [0] += 1 This fails with the following error; TypeError: 'int' object is not iterable I know that others have already solved the problem, but here is something which might help you solve

Re: [Tutor] List of ints

2015-03-03 Thread Phil
On 03/03/15 17:46, Mark Lawrence wrote: You are trying to increment the first element of count which is itself a list containing one element. You actually need:- count[0][0] +=1 Thank you Lawrence, Alan, and Danny, The solution is embarrassingly obvious. It's been a long time since I've

Re: [Tutor] List of ints

2015-03-03 Thread Mark Lawrence
On 03/03/2015 23:09, Phil wrote: On 03/03/15 17:46, Mark Lawrence wrote: You are trying to increment the first element of count which is itself a list containing one element. You actually need:- count[0][0] +=1 Thank you Lawrence, Alan, and Danny, The solution is embarrassingly obvious.

Re: [Tutor] List of ints

2015-03-03 Thread Steven D'Aprano
On Tue, Mar 03, 2015 at 04:50:41PM +1000, Phil wrote: count [0] += 1 This fails with the following error; TypeError: 'int' object is not iterable I know that others have already solved the problem, but here is something which might help you solve similar problems in the future. The way

Re: [Tutor] List of ints

2015-03-03 Thread Steven D'Aprano
On Wed, Mar 04, 2015 at 09:09:03AM +1000, Phil wrote: I'd been away from home for five weeks and during a quiet period I installed QPython on my tablet with the aim of porting a programme that I'd written in C++ 15 years ago to Python. Cutting and pasting and even moving around the IDE

Re: [Tutor] List of ints

2015-03-03 Thread Alan Gauld
On 03/03/15 06:50, Phil wrote: I'd like to set up a two dimensional list of counters as follows; count = [ [0], [0], [0] ] And then increment the first counter as follows; count [0] += 1 Are you trying to increment the zero to make it 1? Or are you trying to add a new value, 1, to the

Re: [Tutor] List of ints

2015-03-03 Thread Danny Yoo
On Mon, Mar 2, 2015 at 10:50 PM, Phil phil_...@bigpond.com wrote: Thank you for reading this. Python 3 under Linux. I'd like to set up a two dimensional list of counters as follows; count = [ [0], [0], [0] ] Can you explain why the list is

Re: [Tutor] List of ints

2015-03-02 Thread Mark Lawrence
On 03/03/2015 06:50, Phil wrote: Thank you for reading this. Python 3 under Linux. I'd like to set up a two dimensional list of counters as follows; count = [ [0], [0], [0] ] And then increment the first counter as follows; count [0] += 1 This

[Tutor] List of ints

2015-03-02 Thread Phil
Thank you for reading this. Python 3 under Linux. I'd like to set up a two dimensional list of counters as follows; count = [ [0], [0], [0] ] And then increment the first counter as follows; count [0] += 1 This fails with the following error;

Re: [Tutor] list comprehension with else

2015-01-19 Thread Sydney Shall
On 19/01/2015 00:55, Steven D'Aprano wrote: On Sun, Jan 18, 2015 at 02:20:55PM -0800, Danny Yoo wrote: Just to add, log(0) is mathematically undefined. https://en.m.wikipedia.org/wiki/Logarithm. For the record, IEEE-754 specifies that log(0.0) should return -INF. That's what Decimal does: py

Re: [Tutor] list comprehension with else

2015-01-18 Thread Steven D'Aprano
On Sun, Jan 18, 2015 at 02:20:55PM -0800, Danny Yoo wrote: Just to add, log(0) is mathematically undefined. https://en.m.wikipedia.org/wiki/Logarithm. For the record, IEEE-754 specifies that log(0.0) should return -INF. That's what Decimal does: py from decimal import Decimal py

Re: [Tutor] list comprehension with else

2015-01-18 Thread Alan Gauld
On 18/01/15 13:20, Sydney Shall wrote: I am a beginner and I have a question of syntax. Please don't hijack an existing thread. Simply changing the subject line is not enough. Always send a new mail to tutor@python.org to start a new discussion. Otherwise the new discussion gets interleaved

Re: [Tutor] list comprehension with else

2015-01-18 Thread Sydney Shall
On 18/01/2015 13:20, Sydney Shall wrote: I am a beginner and I have a question of syntax. I am just learning to use list comprehension, which oc course, I find very helpful indeed. However, I am stuck with a specific problem of how to incorporate an else in a list comp-rehension. I cannot do

Re: [Tutor] list comprehension with else

2015-01-18 Thread Asokan Pichai
On Sun, Jan 18, 2015 at 6:50 PM, Sydney Shall s.sh...@virginmedia.com wrote: I am a beginner and I have a question of syntax. Welcome! I am just learning to use list comprehension, which oc course, I find very helpful indeed. However, I am stuck with a specific problem of how to

Re: [Tutor] list comprehension with else

2015-01-18 Thread Alan Gauld
On 18/01/15 13:20, Sydney Shall wrote: The problem is I am occasionally getting exactly zeros when I need to obtain the logarithm of the number. for i in range(len(cap)): Its usually better to iterate over the collection rather than use indexing: for item in cap: if cap[i] ==

[Tutor] list comprehension with else

2015-01-18 Thread Sydney Shall
I am a beginner and I have a question of syntax. I am just learning to use list comprehension, which oc course, I find very helpful indeed. However, I am stuck with a specific problem of how to incorporate an else in a list comp-rehension. I cannot do it. The following snippet of code does

Re: [Tutor] list comprehension with else

2015-01-18 Thread Sydney Shall
On 18/01/2015 13:41, Asokan Pichai wrote: On Sun, Jan 18, 2015 at 6:50 PM, Sydney Shall s.sh...@virginmedia.com mailto:s.sh...@virginmedia.com wrote: I am a beginner and I have a question of syntax. Welcome! I am just learning to use list comprehension, which oc course, I find

Re: [Tutor] list comprehension with else

2015-01-18 Thread Danny Yoo
Just to add, log(0) is mathematically undefined. https://en.m.wikipedia.org/wiki/Logarithm. So depending on the problem's context, it might be worth asking why log is being applied on this input. Is such input expected? Make sure the code isn't trying to correct for input that shouldn't be

[Tutor] List and dictionary comprehensions

2014-09-29 Thread Armindo Rodrigues
Hi everyone, This is my first post so I don't know if I am asking the correct way so let me know if I messed anything up. ***Please note. My code contains a list of quotes that has many lines. I have noted the beginning and end of the quotes list so you can easily skip and go straight to the

Re: [Tutor] List and dictionary comprehensions

2014-09-29 Thread Alan Gauld
On 28/09/14 03:36, Armindo Rodrigues wrote: have noted the beginning and end of the quotes list so you can easily skip and go straight to the code section. *** It would probably have been better to just delete all but a nfew of the quotes. We don't need all of them to evaluate your code.

Re: [Tutor] List and dictionary comprehensions

2014-09-29 Thread Peter Otten
Armindo Rodrigues wrote: Hi everyone, This is my first post so I don't know if I am asking the correct way so let me know if I messed anything up. ***Please note. My code contains a list of quotes that has many lines. I have noted the beginning and end of the quotes list so you can

Re: [Tutor] List of Lists for three Frames

2014-05-19 Thread Wolfgang Maier
On 17.05.2014 15:26, Alan Gauld wrote: On 17/05/14 08:01, ani wrote: So I thought it would be cool to read a sequence at three different frames, A sequence of what? And whats a frame in this context? ...I've come across a conundrum: how to make a list of lists. outerlist = [] innerlist =

[Tutor] List of Lists for three Frames

2014-05-17 Thread ani
So I thought it would be cool to read a sequence at three different frames, which I have pasted below. However, I've come across a conundrum: how to make a list of lists. See, I'd like a final output that displays data of the type of frame with a + or a - to signify the direction of the read

Re: [Tutor] List of Lists for three Frames

2014-05-17 Thread Peter Otten
ani wrote: So I thought it would be cool to read a sequence at three different frames, which I have pasted below. However, I've come across a conundrum: how to make a list of lists. See, I'd like a final output that displays data of the type of frame with a + or a - to signify the direction

Re: [Tutor] List of Lists for three Frames

2014-05-17 Thread Alan Gauld
On 17/05/14 08:01, ani wrote: So I thought it would be cool to read a sequence at three different frames, A sequence of what? And whats a frame in this context? ...I've come across a conundrum: how to make a list of lists. outerlist = [] innerlist = [1,2,3] outerlist.append(innerlist)

[Tutor] List issues

2014-04-17 Thread Wheeler, Gabriel
Hi Im having trouble completing this function with lists. Im supposed to create a function that will let me know if there are repeating elements so I wrote this and am not sure where the error lies. It is supposed to count the number of times a number appears and if its greater than 1 then it

Re: [Tutor] List issues

2014-04-17 Thread Peter Otten
Wheeler, Gabriel wrote: Im having trouble completing this function with lists. Im supposed to create a function that will let me know if there are repeating elements so I wrote this and am not sure where the error lies. It helps you (and us) a lot if you clearly state the error you are

Re: [Tutor] List issues

2014-04-17 Thread Dave Angel
Wheeler, Gabriel wheel...@seattleu.edu Wrote in message: (not much I could read there. This is a text mailing list, so please tell your mail program to send in text mode, not html. Only parts of your code were visible here, and your question not at all. Fortunately, Peter quoted all or most

Re: [Tutor] List issues

2014-04-17 Thread Albert-Jan Roskam
  - Original Message - From: Dave Angel da...@davea.name To: tutor@python.org Cc: Sent: Thursday, April 17, 2014 12:03 PM Subject: Re: [Tutor] List issues quot;Wheeler, Gabriel wheel...@seattleu.edu Wrote in message: (not much I could read there. This is a text mailing list

Re: [Tutor] List issues

2014-04-17 Thread Danny Yoo
Hi Gabriel, Try lists of non-numbers as your input, and the error should be a little clearer to see. You should see the conceptual error you're making if not everything in your program is numeric. Try: words = ['hello', 'world', 'hello'] print(words.count(0))

Re: [Tutor] list comprehension equivalent to map(function, list item)

2013-12-14 Thread Bo Morris
Thank you for your assistance. Based on your direction, I figured it out. *This... * def add(number): print 1 + int(number) x = ['2', '4', '6', '8', '10', '12'] [add(item) for item in x] *Is the same as... * def add(number): print 1 + int(number) x = ['2', '4', '6', '8', '10',

Re: [Tutor] list comprehension equivalent to map(function, list item)

2013-12-14 Thread Peter Otten
Bo Morris wrote: Thank you for your assistance. Based on your direction, I figured it out. *This... * def add(number): print 1 + int(number) x = ['2', '4', '6', '8', '10', '12'] [add(item) for item in x] *Is the same as... * def add(number): print 1 + int(number)

Re: [Tutor] list comprehension equivalent to map(function, list item)

2013-12-14 Thread spir
On 12/14/2013 10:12 AM, Bo Morris wrote: Thank you for your assistance. Based on your direction, I figured it out. *This... * def add(number): print 1 + int(number) x = ['2', '4', '6', '8', '10', '12'] [add(item) for item in x] *Is the same as... * def add(number): print 1 +

[Tutor] list comprehension equivalent to map(function, list item)

2013-12-13 Thread Bo Morris
i have the following simple function that iterates over the list. It passes the list item into the function and adds the numbers. What would be the equivalent way of writing the map portion with list comprehension? My code is as follows: def add(number): print 1 + int(number) x = ['2',

Re: [Tutor] list comprehension equivalent to map(function, list item)

2013-12-13 Thread Mark Lawrence
On 14/12/2013 01:03, Bo Morris wrote: i have the following simple function that iterates over the list. It passes the list item into the function and adds the numbers. What would be the equivalent way of writing the map portion with list comprehension? My code is as follows: def add(number):

Re: [Tutor] list comprehension equivalent to map(function, list item)

2013-12-13 Thread Amit Saha
On Sat, Dec 14, 2013 at 11:03 AM, Bo Morris crushe...@gmail.com wrote: i have the following simple function that iterates over the list. It passes the list item into the function and adds the numbers. What would be the equivalent way of writing the map portion with list comprehension? My code

Re: [Tutor] list comprehension equivalent to map(function, list item)

2013-12-13 Thread Steven D'Aprano
On Fri, Dec 13, 2013 at 08:03:57PM -0500, Bo Morris wrote: i have the following simple function that iterates over the list. Actually, no it doesn't. One important skill of being a programmer is precision of language. The function add you show below does not iterate over the list, it is the

Re: [Tutor] List Python Question..Please help

2013-09-28 Thread Jacqueline Canales
Thank you guys so much i was able to figure it out. I definitely thought to much into the the problem and made it harder on myself. Cant thank you enough for assisting me. I have one more problem with the coding tho. composers = ['Antheil', 'Saint-Saens', 'Beethoven', 'Easdale', 'Nielsen']

Re: [Tutor] List Python Question..Please help

2013-09-28 Thread Jacqueline Canales
THANK YOU!!! All of you were very helpful!! Will definitely use you guys again for any other issues, glad you challenged me to think rather than giving me the answer!!! On Sat, Sep 28, 2013 at 12:39 AM, Amit Saha amitsaha...@gmail.com wrote: On Sat, Sep 28, 2013 at 3:36 PM, Jacqueline

Re: [Tutor] List Python Question..Please help

2013-09-28 Thread Steven D'Aprano
On Sat, Sep 28, 2013 at 12:36:13AM -0500, Jacqueline Canales wrote: Thank you guys so much i was able to figure it out. I definitely thought to much into the the problem and made it harder on myself. Cant thank you enough for assisting me. I have one more problem with the coding tho.

[Tutor] List Python Question..Please help

2013-09-27 Thread Jacqueline Canales
So I have been trying to do this program using ifs and or loops. I am having a hard time solving this question, If you could please assist me in the right direction. Write a program that lists all the composers on the list ['Antheil', 'Saint-Saens', 'Beethoven', 'Easdale', 'Nielsen'] whose name

Re: [Tutor] List Python Question..Please help

2013-09-27 Thread Amit Saha
On Fri, Sep 27, 2013 at 3:48 PM, Jacqueline Canales jackiexxd...@gmail.com wrote: So I have been trying to do this program using ifs and or loops. I am having a hard time solving this question, If you could please assist me in the right direction. Write a program that lists all the composers

Re: [Tutor] List Python Question..Please help

2013-09-27 Thread Dharmit Shah
Also, comparison is case sensitive. Meaning, 'A' and 'a' are not the same. Hope that helps. :) On Fri, Sep 27, 2013 at 1:14 PM, Amit Saha amitsaha...@gmail.com wrote: On Fri, Sep 27, 2013 at 3:48 PM, Jacqueline Canales jackiexxd...@gmail.com wrote: So I have been trying to do this program

Re: [Tutor] List Python Question..Please help

2013-09-27 Thread Alan Gauld
On 27/09/13 06:48, Jacqueline Canales wrote: So I have been trying to do this program using ifs and or loops. I am having a hard time solving this question, If you could please assist me in the right direction. Happy to. We won't do the homework for you but we will ask leading questions and

Re: [Tutor] List Python Question..Please help

2013-09-27 Thread Steven D'Aprano
Hi Jacqueline, and welcome! Further information below... On Fri, Sep 27, 2013 at 12:48:26AM -0500, Jacqueline Canales wrote: Write a program that lists all the composers on the list ['Antheil', 'Saint-Saens', 'Beethoven', 'Easdale', 'Nielsen'] whose name starts and ends with the same letter

Re: [Tutor] List Python Question..Please help

2013-09-27 Thread 罗彭
Maybe the length of each name matters, too. You should consider whether to skip null('') and single-character('a'). On Fri, Sep 27, 2013 at 3:57 PM, Dharmit Shah shahdhar...@gmail.com wrote: Also, comparison is case sensitive. Meaning, 'A' and 'a' are not the same. Hope that helps. :) On

Re: [Tutor] List Python Question..Please help

2013-09-27 Thread Jacqueline Canales
composers = ['Antheil', 'Saint-Saens', 'Beethoven', 'Easdale', 'Nielsen'] x = 'Antheil' s = 'Saint-Saens' h = 'Beethoven' y = 'Easdale' k = 'Nielsen' if s[0] == 'S' or s[0] == 's' == s[-1] == 'S' or s[-1] == 's': if y[0] == 'E' or y[0] == 'e' == y[-1] == 'E' or y[-1] == 'e': if k[0]

Re: [Tutor] List Python Question..Please help

2013-09-27 Thread Dave Angel
On 27/9/2013 13:04, Jacqueline Canales wrote: composers = ['Antheil', 'Saint-Saens', 'Beethoven', 'Easdale', 'Nielsen'] x = 'Antheil' s = 'Saint-Saens' h = 'Beethoven' y = 'Easdale' k = 'Nielsen' if s[0] == 'S' or s[0] == 's' == s[-1] == 'S' or s[-1] == 's': if y[0] == 'E' or y[0] ==

Re: [Tutor] List Python Question..Please help

2013-09-27 Thread Mark Lawrence
On 27/09/2013 18:04, Jacqueline Canales wrote: composers = ['Antheil', 'Saint-Saens', 'Beethoven', 'Easdale', 'Nielsen'] x = 'Antheil' s = 'Saint-Saens' h = 'Beethoven' y = 'Easdale' k = 'Nielsen' if s[0] == 'S' or s[0] == 's' == s[-1] == 'S' or s[-1] == 's': if y[0] == 'E' or y[0] == 'e'

Re: [Tutor] List Python Question..Please help

2013-09-27 Thread wesley chun
hello, well, i have to say that you've at least made a good start at a solution. right now you're thinking about it very much like a human. try to put yourself into the shoes of a computer: how can we solve this task for just ONE name? once you have that solution, then you can apply the same

  1   2   3   4   5   6   7   >