Re: [Tutor] Lists of duplicates

2017-03-09 Thread Alex Kleider
On 2017-03-09 06:07, Steven D'Aprano wrote: On Wed, Mar 08, 2017 at 08:29:19PM -0800, Alex Kleider wrote: Things like this can usually be broken down into their component parts but I've been unsuccessful doing so: def f(lst): res = {} for item in lst: method_res = res.setdefaul

Re: [Tutor] Lists of duplicates

2017-03-09 Thread Steven D'Aprano
On Wed, Mar 08, 2017 at 08:29:19PM -0800, Alex Kleider wrote: > The algorithm I came up with is: > def make_sublists_of_duplicates(original_list): > frequency_counter = {} > for item in original_list: > _ = frequency_counter.setdefault(item, 0) > frequency_counter[item] +=

Re: [Tutor] Lists of duplicates

2017-03-09 Thread Steven D'Aprano
On Wed, Mar 08, 2017 at 08:29:19PM -0800, Alex Kleider wrote: > Things like this can usually be broken down into their component parts > but I've been unsuccessful doing so: > > def f(lst): > res = {} > for item in lst: > method_res = res.setdefault(item, []) > res.method

Re: [Tutor] Lists of duplicates

2017-03-09 Thread Steven D'Aprano
On Thu, Mar 09, 2017 at 01:26:26AM +0530, Sri Kavi wrote: > I wrote and submitted the following function: > > def sublist_duplicates(lst): > sublists = [] > for item in set(lst): > sublists.append([item] * lst.count(item)) > return sublists > > lst_of_duplicates = [1, 2, 10,

Re: [Tutor] Lists of duplicates

2017-03-09 Thread Mats Wichmann
On 03/08/2017 12:56 PM, Sri Kavi wrote: > As part of my learning, I was participating in a discussion at: > > > > https://discuss.codecademy.com/t/python-lists-of-duplicated-elements/78151 > > > > It’s about making a function that returns a list of lists, with each list > being all of the ele

Re: [Tutor] Lists of duplicates

2017-03-09 Thread Alan Gauld via Tutor
On 09/03/17 06:06, Alex Kleider wrote: > It seems you are simply kicking the can down the road rather than > explaining how it it is that dot notation actually works. The dot notation is just a method access. Dictionaries are like any other object and have many methods. > To access a dictionary

Re: [Tutor] Lists of duplicates

2017-03-09 Thread Alan Gauld via Tutor
On 09/03/17 04:29, Alex Kleider wrote: >> I'd probably opt for a dictionary: >> >> def f(lst): >> res = {} >> for item in lst: >> res.setdefault(item,[]).append(item) >> return list(res.values()) >> > The above works BUT > how setdefault returns the current value for the key

Re: [Tutor] Lists of duplicates

2017-03-09 Thread Peter Otten
Alan Gauld via Tutor wrote: > On 08/03/17 19:56, Sri Kavi wrote: > >> It’s about making a function that returns a list of lists, with each list >> being all of the elements that are the same as another element in the >> original list. > > This is one of those problems where there is probably no

Re: [Tutor] Lists of duplicates

2017-03-08 Thread Alex Kleider
On 2017-03-08 21:14, boB Stepp wrote: Alex, I think you can break this down as follows: py3: res = {} py3: def key_item_to_res(item): ... res.setdefault(item, []).append(item) ... py3: key_item_to_res(3) py3: res {3: [3]} py3: key_item_to_res(3) py3: res {3: [3, 3]} py3: key_item_to_res(2)

Re: [Tutor] Lists of duplicates

2017-03-08 Thread boB Stepp
On Wed, Mar 8, 2017 at 10:29 PM, Alex Kleider wrote: > On 2017-03-08 17:03, Alan Gauld via Tutor wrote: >> >> My first reaction was to sort the initial list then iterate >> over it creating a new sublist for each change of value. >> But, it only works for homogenous lists. For mixed types >> I'd

Re: [Tutor] Lists of duplicates

2017-03-08 Thread Alex Kleider
On 2017-03-08 17:03, Alan Gauld via Tutor wrote: On 08/03/17 19:56, Sri Kavi wrote: It’s about making a function that returns a list of lists, with each list being all of the elements that are the same as another element in the original list. This is one of those problems where there is prob

Re: [Tutor] Lists of duplicates

2017-03-08 Thread Alan Gauld via Tutor
On 08/03/17 19:56, Sri Kavi wrote: > It’s about making a function that returns a list of lists, with each list > being all of the elements that are the same as another element in the > original list. This is one of those problems where there is probably no definitive "correct" answer just differe

[Tutor] Lists of duplicates

2017-03-08 Thread Sri Kavi
As part of my learning, I was participating in a discussion at: https://discuss.codecademy.com/t/python-lists-of-duplicated-elements/78151 It’s about making a function that returns a list of lists, with each list being all of the elements that are the same as another element in the original l

Re: [Tutor] lists+sort

2016-01-05 Thread Peter Otten
Pooja Bhalode wrote: > Hi, I wanted to check if this program can be used to merge the lists > together and sort them. This seems to work, but i wanted to check if there > are drawbacks in writing it in this manner. When you start out lists are the natural datatype to use, but as you get more exp

Re: [Tutor] lists+sort

2016-01-05 Thread Steven D'Aprano
On Mon, Jan 04, 2016 at 12:34:57PM -0500, Pooja Bhalode wrote: > Hi, I wanted to check if this program can be used to merge the lists > together and sort them. This seems to work, but i wanted to check if there > are drawbacks in writing it in this manner. > > My solution: > > def linear_merge(li

Re: [Tutor] lists+sort

2016-01-04 Thread Danny Yoo
> > You may also take a look at this link: > http://stackoverflow.com/questions/7237875/linear-merging-for-lists-in-python > > It appears that the poster was going through Googles python tutorials Hi Joel, Ah. Nice catch! Yes, that looks like it. It looks like this comes from the material at h

Re: [Tutor] lists+sort

2016-01-04 Thread Joel Goldstick
On Mon, Jan 4, 2016 at 5:35 PM, Danny Yoo wrote: > On Jan 4, 2016 11:00 AM, "Pooja Bhalode" wrote: > > > > Hi, I wanted to check if this program can be used to merge the lists > > together and sort them. This seems to work, but i wanted to check if > there > > are drawbacks in writing it in this

Re: [Tutor] lists+sort

2016-01-04 Thread Danny Yoo
On Jan 4, 2016 11:00 AM, "Pooja Bhalode" wrote: > > Hi, I wanted to check if this program can be used to merge the lists > together and sort them. This seems to work, but i wanted to check if there > are drawbacks in writing it in this manner. You may be missing some important details or misunder

Re: [Tutor] lists+sort

2016-01-04 Thread Joel Goldstick
On Mon, Jan 4, 2016 at 12:34 PM, Pooja Bhalode wrote: > Hi, I wanted to check if this program can be used to merge the lists > together and sort them. This seems to work, but i wanted to check if there > are drawbacks in writing it in this manner. > > > My solution: > > > def linear_merge(list1,

Re: [Tutor] Lists+sorting

2016-01-04 Thread Pooja Bhalode
Hi, Yes, I tried sending the mail again in plain text. But I think I understood the difference there in using built-in sort function and writing the code without using that. Thank you On Mon, Jan 4, 2016 at 12:45 PM, Joel Goldstick wrote: > On Mon, Jan 4, 2016 at 12:27 PM, Alan Gauld > wrote

[Tutor] lists+sort

2016-01-04 Thread Pooja Bhalode
Hi, I wanted to check if this program can be used to merge the lists together and sort them. This seems to work, but i wanted to check if there are drawbacks in writing it in this manner. My solution: def linear_merge(list1, list2): for num in list2: list1.append(num) list1

Re: [Tutor] Lists+sorting

2016-01-04 Thread Joel Goldstick
On Mon, Jan 4, 2016 at 12:27 PM, Alan Gauld wrote: > On 04/01/16 16:56, Pooja Bhalode wrote: > > Hi, > > I wanted to check if I can write the following program in this manner as > > well. > > > > Can you resend in plain text please? > Your post lost all its formatting so its hard to read > or com

Re: [Tutor] Lists+sorting

2016-01-04 Thread Alan Gauld
On 04/01/16 16:56, Pooja Bhalode wrote: > Hi, > I wanted to check if I can write the following program in this manner as > well. > Can you resend in plain text please? Your post lost all its formatting so its hard to read or comment on. > def linear_merge(list1, list2): > result = [] > while len

[Tutor] Lists+sorting

2016-01-04 Thread Pooja Bhalode
Hi, I wanted to check if I can write the following program in this manner as well. The problem is to merge the lists together and sort them.The solution they have given is: def linear_merge(list1, list2): result = [] while len(list1) and len(list2): if list1[0] < list2[0]: result.append(list

Re: [Tutor] lists, name semantics

2015-04-19 Thread Alan Gauld
On 20/04/15 00:29, Laura Creighton wrote: So in this case, the binding value is an integer, not an address. Utterly wrong. The binding value has to be an address. I think it depends on how you define 'binding' value. In Python binding is the connection between a name and an object. So in a

Re: [Tutor] lists, name semantics

2015-04-19 Thread Laura Creighton
In a message of Sun, 19 Apr 2015 19:19:27 -0400, Dave Angel writes: >Good answer. The java jvm garbage collector is free to move blocks >around to defrag the free space. Correct. >FWIW, I'm told the ID value used is a simple integer, that indexes a >list containing the actual addresses. Also

Re: [Tutor] lists, name semantics

2015-04-19 Thread Laura Creighton
In a message of Sun, 19 Apr 2015 17:23:13 -0500, boB Stepp writes: >The last sentence in this paragraph has me intrigued. Why would an >object, once it has been created, be moved? What practical benefit >does doing this give? > boB If you have more than enough memory in your system, you never do t

Re: [Tutor] lists, name semantics

2015-04-19 Thread Laura Creighton
In a message of Sun, 19 Apr 2015 17:23:13 -0500, boB Stepp writes: >On Sun, Apr 19, 2015 at 4:05 PM, Dave Angel wrote: >> abstract, and the details are unimportant to the user. For example, the >> jython system does not use addresses at all. And an object gets moved >> around from time to time w

Re: [Tutor] lists, name semantics

2015-04-19 Thread Dave Angel
On 04/19/2015 06:28 PM, Joel Goldstick wrote: On Sun, Apr 19, 2015 at 6:23 PM, boB Stepp wrote: On Sun, Apr 19, 2015 at 4:05 PM, Dave Angel wrote: On 04/19/2015 03:08 PM, boB Stepp wrote: Or is the real point that we are adding an abstraction layer so we don't even have to think about wh

Re: [Tutor] lists, name semantics

2015-04-19 Thread Joel Goldstick
On Sun, Apr 19, 2015 at 6:23 PM, boB Stepp wrote: > On Sun, Apr 19, 2015 at 4:05 PM, Dave Angel wrote: >> On 04/19/2015 03:08 PM, boB Stepp wrote: >>> > >>> Or is the real point that we are adding an abstraction >>> layer so we don't even have to think about where objects are >>> physically store

Re: [Tutor] lists, name semantics

2015-04-19 Thread boB Stepp
On Sun, Apr 19, 2015 at 4:05 PM, Dave Angel wrote: > On 04/19/2015 03:08 PM, boB Stepp wrote: >> >> Or is the real point that we are adding an abstraction >> layer so we don't even have to think about where objects are >> physically stored in RAM? > > > Somebody keeps track, but the address is no

Re: [Tutor] lists, name semantics

2015-04-19 Thread Dave Angel
On 04/19/2015 03:08 PM, boB Stepp wrote: On Sun, Apr 19, 2015 at 6:47 AM, Dave Angel wrote: On 04/19/2015 12:07 AM, boB Stepp wrote: [...] I hope this is helpful, and, if there are any misstepps, that when they are revealed both of our understandings will be enhanced! Some of your knowle

Re: [Tutor] lists, name semantics

2015-04-19 Thread boB Stepp
On Sun, Apr 19, 2015 at 6:47 AM, Dave Angel wrote: > On 04/19/2015 12:07 AM, boB Stepp wrote: [...] >> I hope this is helpful, and, if there are any misstepps, that when >> they are revealed both of our understandings will be enhanced! >> > > Some of your knowledge of other languages is leaking

Re: [Tutor] lists, name semantics

2015-04-19 Thread boB Stepp
On Sun, Apr 19, 2015 at 12:24 AM, Cameron Simpson wrote: > On 19Apr2015 15:09, Cameron Simpson wrote: >> >> On 18Apr2015 23:26, boB Stepp wrote: >>> >>> On Sat, Apr 18, 2015 at 11:08 PM, Cameron Simpson wrote: [...] >>> "Two problems often exist with deep copy operations that don’t exist >>>

Re: [Tutor] lists, name semantics

2015-04-19 Thread Dave Angel
On 04/19/2015 12:07 AM, boB Stepp wrote: . Before Peter changed one of these changeable objects, he had: a = [1, ["x", "y"], 3] b = a[:] Now BOTH a[1] and b[1] now identify the location of the inner list object, ["x", "y"] . Apparently, Python, in its ever efficient memory management fash

Re: [Tutor] lists, name semantics

2015-04-18 Thread Cameron Simpson
On 19Apr2015 15:09, Cameron Simpson wrote: On 18Apr2015 23:26, boB Stepp wrote: On Sat, Apr 18, 2015 at 11:08 PM, Cameron Simpson wrote: Sometimes you want a "deep" copy, where "b" would have got a copy of the iriginal x-y list. See the "copy" module's "deepcopy" function, which supplies thi

Re: [Tutor] lists, name semantics

2015-04-18 Thread Cameron Simpson
On 18Apr2015 23:26, boB Stepp wrote: On Sat, Apr 18, 2015 at 11:08 PM, Cameron Simpson wrote: Sometimes you want a "deep" copy, where "b" would have got a copy of the iriginal x-y list. See the "copy" module's "deepcopy" function, which supplies this for when it is needed: https://docs.pytho

Re: [Tutor] lists, name semantics

2015-04-18 Thread boB Stepp
On Sat, Apr 18, 2015 at 11:08 PM, Cameron Simpson wrote: > Sometimes you want a "deep" copy, where "b" would have got a copy of the > iriginal x-y list. See the "copy" module's "deepcopy" function, which > supplies this for when it is needed: > > https://docs.python.org/3/library/copy.html#copy.

Re: [Tutor] lists, name semantics

2015-04-18 Thread Cameron Simpson
On 18Apr2015 22:03, Bill Allen wrote: On Apr 18, 2015 4:11 PM, "boB Stepp" wrote: On Sat, Apr 18, 2015 at 3:28 PM, Bill Allen wrote: > On Apr 18, 2015 7:50 AM, "Peter Otten" <__pete...@web.de> wrote: >> You can test your newfound knowledge by predicting the output of the >> following script:

Re: [Tutor] lists, name semantics

2015-04-18 Thread boB Stepp
On Sat, Apr 18, 2015 at 10:03 PM, Bill Allen wrote: > > On Apr 18, 2015 4:11 PM, "boB Stepp" wrote: >> >> On Sat, Apr 18, 2015 at 3:28 PM, Bill Allen wrote: >> > On Apr 18, 2015 7:50 AM, "Peter Otten" <__pete...@web.de> wrote: >> > >> >> Bill Allen wrote: [...] >> >> You can test your newfound

Re: [Tutor] lists, name semantics

2015-04-18 Thread Bill Allen
On Apr 18, 2015 4:11 PM, "boB Stepp" wrote: > > On Sat, Apr 18, 2015 at 3:28 PM, Bill Allen wrote: > > On Apr 18, 2015 7:50 AM, "Peter Otten" <__pete...@web.de> wrote: > > > >> Bill Allen wrote: > >> > >> > Everyone that responded, > >> > > >> > Thanks very much for the excellent explanations! T

Re: [Tutor] lists, name semantics

2015-04-18 Thread boB Stepp
On Sat, Apr 18, 2015 at 3:28 PM, Bill Allen wrote: > On Apr 18, 2015 7:50 AM, "Peter Otten" <__pete...@web.de> wrote: > >> Bill Allen wrote: >> >> > Everyone that responded, >> > >> > Thanks very much for the excellent explanations! The distinction between >> > a reference to an object and a sepe

Re: [Tutor] lists, name semantics

2015-04-18 Thread Bill Allen
print(b) will print the original copy of a which b now references which is [1, ["x", "y"], 3] On Apr 18, 2015 7:50 AM, "Peter Otten" <__pete...@web.de> wrote: > Bill Allen wrote: > > > Everyone that responded, > > > > Thanks very much for the excellent explanations! The distinction between > > a

Re: [Tutor] lists, name semantics

2015-04-18 Thread Peter Otten
Bill Allen wrote: > Everyone that responded, > > Thanks very much for the excellent explanations! The distinction between > a reference to an object and a seperate copy of the object is quite clear > now. You can test your newfound knowledge by predicting the output of the following script:

Re: [Tutor] lists, name semantics

2015-04-18 Thread Bill Allen
Everyone that responded, Thanks very much for the excellent explanations! The distinction between a reference to an object and a seperate copy of the object is quite clear now. --Bill On Apr 18, 2015 1:44 AM, "Alan Gauld" wrote: > On 18/04/15 04:16, Bill Allen wrote: > >> If I have a list defi

Re: [Tutor] lists, name semantics

2015-04-17 Thread Alan Gauld
On 18/04/15 04:16, Bill Allen wrote: If I have a list defined as my_list = ['a','b','c'], what is the is differnce between refering to it as my_list or my_list[:]? These seem equivalent to me. Is that the case? Is there any nuance I am missing here? Situations where one form should be used

Re: [Tutor] lists, name semantics

2015-04-17 Thread Dave Angel
On 04/17/2015 11:51 PM, Ben Finney wrote: Ben Finney writes: Bill Allen writes: If I have a list defined as my_list = ['a','b','c'], what is the is differnce between refering to it as my_list or my_list[:]? ‘my_list’ is a reference to the object you've already described (the existing obje

Re: [Tutor] lists, name semantics

2015-04-17 Thread Ben Finney
Ben Finney writes: > Bill Allen writes: > > > If I have a list defined as my_list = ['a','b','c'], what is the is > > differnce between refering to it as my_list or my_list[:]? > > ‘my_list’ is a reference to the object you've already described (the > existing object ‘['a', 'b', 'c']’). > > ‘my_

Re: [Tutor] lists, name semantics

2015-04-17 Thread Martin A. Brown
Good evening Bill, If I have a list defined as my_list = ['a','b','c'], what is the is differnce between refering to it as my_list or my_list[:]? These seem equivalent to me. Is that the case? Is there any nuance I am missing here? Situations where one form should be used as opposed to th

Re: [Tutor] lists, name semantics

2015-04-17 Thread Ben Finney
Bill Allen writes: > If I have a list defined as my_list = ['a','b','c'], what is the is > differnce between refering to it as my_list or my_list[:]? ‘my_list’ is a reference to the object you've already described (the existing object ‘['a', 'b', 'c']’). ‘my_list[:]’ is an operation that takes

[Tutor] lists, name semantics

2015-04-17 Thread Bill Allen
If I have a list defined as my_list = ['a','b','c'], what is the is differnce between refering to it as my_list or my_list[:]? These seem equivalent to me. Is that the case? Is there any nuance I am missing here? Situations where one form should be used as opposed to the other? Thanks, Bill

Re: [Tutor] lists of lists: more Chutes & Ladders!

2014-01-01 Thread Mark Lawrence
On 01/01/2014 08:04, Danny Yoo wrote: My point was: `iter` the func exists in python (built-in with '-'), one may use it at times. Giving an application var this name hides, which accosionnally leads to bugs. I have been bitten by such a bug more than once in the past, and once hard to find, asp.

Re: [Tutor] lists of lists: more Chutes & Ladders!

2014-01-01 Thread Danny Yoo
> My point was: `iter` the func exists in python (built-in with '-'), one may > use it at times. Giving an application var this name hides, which > accosionnally leads to bugs. I have been bitten by such a bug more than once > in the past, and once hard to find, asp. with the built-in func `range`

Re: [Tutor] lists of lists: more Chutes & Ladders!

2013-12-31 Thread spir
On 01/01/2014 07:13 AM, eryksun wrote: >I'm afraid I've lost the context, and don't understand why this is >important. It's true that not all built-in objects are in builtins, and >not all objects in builtins are built-in, but other than for pedantic >correctness, why does this matter? Denis sai

Re: [Tutor] lists of lists: more Chutes & Ladders!

2013-12-31 Thread eryksun
On Tue, Dec 31, 2013 at 10:53 PM, Steven D'Aprano wrote: > > __builtins__ with-an-s is a crappy hack that has never worked correctly > and has caused more confusion than help: > > https://mail.python.org/pipermail/python-3000/2007-March/006170.html > > "Restricted mode" in CPython has never worked

Re: [Tutor] lists of lists: more Chutes & Ladders!

2013-12-31 Thread Steven D'Aprano
On Tue, Dec 31, 2013 at 10:00:32PM -0500, eryksun wrote: > On Tue, Dec 31, 2013 at 4:27 AM, spir wrote: > > In addition, "iter" is also the name of a builtin function, like "print". > > While iter is a built-in function, it would be clearer if you > referenced the __builtins__ namespace. Don't

Re: [Tutor] lists of lists: more Chutes & Ladders!

2013-12-31 Thread eryksun
On Tue, Dec 31, 2013 at 4:27 AM, spir wrote: > In addition, "iter" is also the name of a builtin function, like "print". While iter is a built-in function, it would be clearer if you referenced the __builtins__ namespace. Built-in objects are linked into the interpreter, either statically or from

Re: [Tutor] lists of lists: more Chutes & Ladders!

2013-12-31 Thread spir
On 12/31/2013 09:46 PM, Keith Winston wrote: Thanks Denis, I found out about the iter builtin last night, a few hours after I'd coded/posted that. Oops. Thanks for your other comments, I am clearer now about the distinction of creating a new, empty list vs. clearing the same list out, and the sub

Re: [Tutor] lists of lists: more Chutes & Ladders!

2013-12-31 Thread Keith Winston
Thanks Denis, I found out about the iter builtin last night, a few hours after I'd coded/posted that. Oops. Thanks for your other comments, I am clearer now about the distinction of creating a new, empty list vs. clearing the same list out, and the subsequent implications on other symbols bound to

Re: [Tutor] lists of lists: more Chutes & Ladders!

2013-12-31 Thread spir
On 12/31/2013 06:59 AM, Keith Winston wrote: I resolved a problem I was having with lists, but I don't understand how! I caught my code inadvertently resetting/zeroing two lists TWICE at the invocation of the game method, and it was leading to all the (gamechutes & gameladders) lists returned by

Re: [Tutor] lists of lists: more Chutes & Ladders!

2013-12-31 Thread Mark Lawrence
On 31/12/2013 07:30, Keith Winston wrote: Never mind, I figured out that the slice assignment is emptying the previous lists, before the .reset() statements are creating new lists that I then populate and pass on. It makes sense. On Tue, Dec 31, 2013 at 12:59 AM, Keith Winston mailto:keithw...@g

Re: [Tutor] lists of lists: more Chutes & Ladders!

2013-12-30 Thread Keith Winston
Never mind, I figured out that the slice assignment is emptying the previous lists, before the .reset() statements are creating new lists that I then populate and pass on. It makes sense. On Tue, Dec 31, 2013 at 12:59 AM, Keith Winston wrote: > I resolved a problem I was having with lists, but

[Tutor] lists of lists: more Chutes & Ladders!

2013-12-30 Thread Keith Winston
I resolved a problem I was having with lists, but I don't understand how! I caught my code inadvertently resetting/zeroing two lists TWICE at the invocation of the game method, and it was leading to all the (gamechutes & gameladders) lists returned by that method being zeroed out except the final t

Re: [Tutor] Lists and While Loops

2012-03-28 Thread Ricky Brown
Thank you all for your input it was extremely helpful. Robert you were spot on with what I was trying to do, I tried to implement the random.sample earlier but I couldn't see to get it too work -- running smoothly now. Sorry for the trouble :) On Wed, Mar 28, 2012 at 4:14 PM, Robert Sjoblom wrote

Re: [Tutor] Lists and While Loops

2012-03-28 Thread Mark Lawrence
On 28/03/2012 21:15, Emile van Sebille wrote: On 3/28/2012 11:53 AM Ricky Brown said... So I have to write a program that reads a message from the user and prints a new message ok -- that contains all the words from the original message but in the same order without repeating any of them unl

Re: [Tutor] Lists and While Loops

2012-03-28 Thread James Reynolds
On Wed, Mar 28, 2012 at 2:53 PM, Ricky Brown wrote: > So I have to write a program that reads a message from the user and prints > a new message that contains all the words from the original message but in > the same order without repeating any of them unless they show up more than > once in the

Re: [Tutor] Lists and While Loops

2012-03-28 Thread Emile van Sebille
On 3/28/2012 11:53 AM Ricky Brown said... So I have to write a program that reads a message from the user and prints a new message ok -- that contains all the words from the original message but in the same order without repeating any of them unless they show up more than once in the original

Re: [Tutor] Lists and While Loops

2012-03-28 Thread Robert Sjoblom
> I can't figure out > 1) How to remove "y" from the list and continue the loop; when I use .remove > etc. it runs once then give me the error that "y" is not in the list. > > I imagine the answer is quite simple I'm just getting really frustrated > trying to get this done any advice is appreciated

[Tutor] Lists and While Loops

2012-03-28 Thread Ricky Brown
So I have to write a program that reads a message from the user and prints a new message that contains all the words from the original message but in the same order without repeating any of them unless they show up more than once in the original message. What I have thus far looks like this: mess

Re: [Tutor] Lists/raw_input

2012-02-06 Thread Christian Witts
On 2012/02/07 07:40 AM, Michael Lewis wrote: I want to prompt the user only once to enter 5 numbers. I then want to create a list out of those five numbers. How can I do that? I know how to do it if I prompt the user 5 different times, but I only want to prompt the user once. Thanks. -- Mic

Re: [Tutor] Lists/raw_input

2012-02-06 Thread Andre' Walker-Loud
Hi Michael, I bet there is a better way (which I would like to see), but here is what I have come up with for my own uses. """ ints = [] u_in = False while u_in == False: try: u_input = raw_input('please enter 5 integers, space separated\n ') for n in

[Tutor] Lists/raw_input

2012-02-06 Thread Michael Lewis
I want to prompt the user only once to enter 5 numbers. I then want to create a list out of those five numbers. How can I do that? I know how to do it if I prompt the user 5 different times, but I only want to prompt the user once. Thanks. -- Michael

Re: [Tutor] Lists

2011-06-13 Thread Kĩnũthia Mũchane
4:06 PM To: tutor@python.org Subject: Re: [Tutor] Lists Dnia 11-06-2011 o 17:51:03 Piotr Kamiński napisał(a): Dnia 11-06-2011 o 17:30:50 Alan Gauld napisał(a): "Piotr Kamiński" wrote This is a *technical* list, as I understand it, solely dedicated to ... Since this seems to be

Re: [Tutor] Lists

2011-06-12 Thread R. Berman
-Original Message- > From: tutor-bounces+bermanrl=cfl.rr@python.org [mailto:tutor- > bounces+bermanrl=cfl.rr@python.org] On Behalf Of Piotr Kaminski > Sent: Sunday, June 12, 2011 4:06 PM > To: tutor@python.org > Subject: Re: [Tutor] Lists > > Dnia 11-06-2011 o 17

Re: [Tutor] Lists

2011-06-12 Thread Piotr Kamiński
Dnia 11-06-2011 o 17:51:03 Piotr Kamiński napisał(a): Dnia 11-06-2011 o 17:30:50 Alan Gauld napisał(a): "Piotr Kamiński" wrote This is a *technical* list, as I understand it, solely dedicated to ... Since this seems to be something we can all agree on can we consider this discussion

Re: [Tutor] Lists

2011-06-11 Thread Jeff Johnson
Alan: Thank you for all you do. I always look for your posts! You have helped me immensely with Python and I appreciate it! Jeff --- Jeff Johnson j...@dcsoftware.com Jeff --- Jeff Johnson j...@san-dc.com (623) 582-0323 www.san-dc.com On 06/11/2011 08:30

Re: [Tutor] Lists

2011-06-11 Thread Kĩnũthia Mũchane
On 06/11/2011 06:51 PM, Piotr Kamiński wrote: Dnia 11-06-2011 o 17:30:50 Alan Gauld napisał(a): "Piotr Kamiński" wrote This is a *technical* list, as I understand it, solely dedicated to the technical side of teaching the *Python* programming language and *programming* in general. I woul

Re: [Tutor] Lists

2011-06-11 Thread Piotr Kamiński
Dnia 11-06-2011 o 17:30:50 Alan Gauld napisał(a): "Piotr Kamiński" wrote This is a *technical* list, as I understand it, solely dedicated to the technical side of teaching the *Python* programming language and *programming* in general. I would like to keep it this way ... Since this s

Re: [Tutor] Lists

2011-06-11 Thread Piotr Kamiński
Hello, I've been told that some of you, or everybody got my e-mail four times. I'm sorry for the inconvenience. It seems there was a temporary failure of my piotr-kam[at]o2.pl mail account. I tried to send the e-mail three times, and each time got the "Undelivered Mail Returned to Sender" me

Re: [Tutor] Lists

2011-06-11 Thread Alan Gauld
"Piotr Kamiński" wrote This is a *technical* list, as I understand it, solely dedicated to the technical side of teaching the *Python* programming language and *programming* in general. I would like to keep it this way ... Since this seems to be something we can all agree on can we consider

Re: [Tutor] Lists

2011-06-11 Thread Piotr Kamiński
Dnia 11-06-2011 o 04:34:47 Steven D'Aprano napisał(a): Piotr Kamiński wrote: Could you please refrain from presenting your *religious* convictions in this list: the notions you believe in as well as the ones that you believe are false? This is a *technical* list, as I understand it, solel

Re: [Tutor] Lists

2011-06-10 Thread eizetov
Vincent, you should also try to avoid naming your lists a 'list'. There's a couple dozen words in Python that are reserved 'for system use': import keyword print(keyword.kwlist) ['False', 'None', 'True', 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'exce

Re: [Tutor] Lists

2011-06-10 Thread Steven D'Aprano
Piotr Kamiński wrote: Could you please refrain from presenting your *religious* convictions in this list: the notions you believe in as well as the ones that you believe are false? This is a *technical* list, as I understand it, solely dedicated to the technical side of teaching the *Python* pr

Re: [Tutor] Lists

2011-06-10 Thread Piotr Kamiński
Dnia 10-06-2011 o 22:00:46 Corey Richardson napisał(a): On 06/10/2011 03:12 PM, Piotr Kamiński wrote: Could you please refrain from presenting your *religious* convictions in this list: the notions you believe in as well as the ones that you believe are false? This is a *technical* list, as I

Re: [Tutor] Lists

2011-06-10 Thread Corey Richardson
On 06/10/2011 03:12 PM, Piotr Kamiński wrote: > Could you please refrain from presenting your *religious* convictions > in this list: the notions you believe in as well as the ones that you > believe are false? > > This is a *technical* list, as I understand it, solely dedicated to > the technical

Re: [Tutor] Lists

2011-06-10 Thread Piotr Kamiński
Dnia 10-06-2011 o 12:25:34 Steven D'Aprano napisał(a): Vincent Balmori wrote: I'm stuck on two problems from the Absolute Beginners book. The first is simple. I am trying to print all the words in the list in random order without repeats, but it always shows None for some reason. #Program

Re: [Tutor] Lists

2011-06-10 Thread Steven D'Aprano
Vincent Balmori wrote: I'm stuck on two problems from the Absolute Beginners book. The first is simple. I am trying to print all the words in the list in random order without repeats, but it always shows None for some reason. #Program prints list of words in random order with no repeats impor

[Tutor] Lists

2011-06-10 Thread Vincent Balmori
I'm stuck on two problems from the Absolute Beginners book. The first is simple. I am trying to print all the words in the list in random order without repeats, but it always shows None for some reason. #Program prints list of words in random order with no repeats import random #List of words

Re: [Tutor] lists, arrays and saving data

2010-11-21 Thread Corey Richardson
On 11/21/2010 8:12 AM, Chris Begert wrote: Hi Gurus I just wrote my first little python program; so yes I'm very new to all this. The goal in the end is to have a program that shows how the sun moves from the point of view of a given location (i.e. solar paths added to some sort of stereog

Re: [Tutor] lists, arrays and saving data

2010-11-21 Thread Alan Gauld
"Chris Begert" wrote How do I store a years worth of data of angles in an array / list / whatever is most useful when using Python? The choice of data structure usually depends on how you plan on accessing/using it. So we can't advise until we know more about what you plan on doing with it! T

Re: [Tutor] lists, arrays and saving data

2010-11-21 Thread Emile van Sebille
On 11/21/2010 5:12 AM Chris Begert said... Hi Gurus I just wrote my first little python program; so yes I'm very new to all this. The goal in the end is to have a program that shows how the sun moves from the point of view of a given location (i.e. solar paths added to some sort of stereogra

[Tutor] lists, arrays and saving data

2010-11-21 Thread Chris Begert
Hi Gurus I just wrote my first little python program; so yes I'm very new to all this. The goal in the end is to have a program that shows how the sun moves from the point of view of a given location (i.e. solar paths added to some sort of stereographic diagram). My very first program calcula

Re: [Tutor] Lists in a file

2009-04-27 Thread David Holland
Thanks for all the suggestions.  I will have to try this. --- On Sun, 26/4/09, Kent Johnson wrote: From: Kent Johnson Subject: Re: [Tutor] Lists in a file To: "Robert Berman" Cc: "David Holland" , "tutor python" Date: Sunday, 26 April, 2009, 8:04 PM On Sun, A

Re: [Tutor] Lists in a file

2009-04-26 Thread spir
Le Sun, 26 Apr 2009 18:03:41 + (GMT), David Holland s'exprima ainsi: > Hi, > > I am trying to create a program where I open a file full of lists and > process them. However when the program does not recognize the lists as > lists. Here is the relevant code :- > def open_filedef(): >     text

Re: [Tutor] Lists in a file

2009-04-26 Thread Kent Johnson
On Sun, Apr 26, 2009 at 2:18 PM, Robert Berman wrote: > David, > > You are processing a text file. It is your job to treat it as a file > comprised of lists. I think what you are saying is that each line in the > text file is a list. In that case > > for line in fileobject: >   listline = list(lin

Re: [Tutor] Lists in a file

2009-04-26 Thread Robert Berman
David, You are processing a text file. It is your job to treat it as a file comprised of lists. I think what you are saying is that each line in the text file is a list. In that case for line in fileobject: listline = list(line) Now, listline is a list of the text items in line. Hope thi

[Tutor] Lists in a file

2009-04-26 Thread David Holland
Hi, I am trying to create a program where I open a file full of lists and process them. However when the program does not recognize the lists as lists. Here is the relevant code :- def open_filedef():     text_file =open ("voteinp.txt","r")     lines = text_file.readlines()             for line

Re: [Tutor] lists

2009-01-20 Thread David
Norman Khine wrote: > Hi, > actually what I was trying to do carries from my last post, where my > media files are a list that I want to add to the > > subprocess.call(['sox', ', '.join(media_list), 'list.wav']) Something like this may work; #!/usr/bin/python import subprocess def play(filename):

Re: [Tutor] lists

2009-01-20 Thread Kent Johnson
On Tue, Jan 20, 2009 at 1:02 PM, Norman Khine wrote: > Hi, > actually what I was trying to do carries from my last post, where my media > files are a list that I want to add to the > > subprocess.call(['sox', ', '.join(media_list), 'list.wav']) OK, you want a list, not a string. You can use + to

Re: [Tutor] lists

2009-01-20 Thread Norman Khine
Hi, actually what I was trying to do carries from my last post, where my media files are a list that I want to add to the subprocess.call(['sox', ', '.join(media_list), 'list.wav']) >>> print ', '.join(media_list) upper_b.wav, upper_a.wav >>> subprocess.call(['sox', ', '.join(media_list), 'lis

  1   2   >