Sanhita Mallick wrote:
help
YOU ARE STANDING AT THE END OF A ROAD BEFORE A SMALL BRICK
BUILDING . AROUND YOU IS A FOREST. A SMALL
STREAM FLOWS OUT OF THE BUILDING AND DOWN A GULLY.
Emile
___
Tutor maillist - Tutor@python.org
http://mail.python
Just glancing at your program, I would guess that you have a ":" where you
want a "]" on the line below.
prod = prod * letter_to_prime[word_list[j] [i]:
HTH,
Chris
jessica cruz
Sent by: tutor-bounces+christopher.henk=allisontransmission@python.org
03/09/2009 02:38 PM
To
Tutor@p
On Mon, Mar 9, 2009 at 10:38 AM, jessica cruz wrote:
> I made this program but it says that there is an error and I have a hard
> time trying to solve the problem with program.
> :
> I don't know how to figure out the error since the only message that I get
> is that "there's an error: inva
On Mon, Mar 9, 2009 at 1:38 PM, jessica cruz wrote:
> I don't know how to figure out the error since the only message that I get
> is that "there's an error: invalid syntax"
Please copy & paste the whole error message including the traceback so
we know where the error is.
Kent
_
"David" wrote
def uses_all(word, required):
for letter in required:
if letter not in word:
return False
return True
Now, I want to feed this code a list of words. This is what I have
so far:
def uses_all(required):
It is usually better to leave things that work a
2009/2/10 David :
> Dear list,
>
> out of "Thinking in Python" I take the following code, which
> "takes a word and a string of required letters, and that returns True if
> the word uses all the required letters at least once".
>
>
> def uses_all(word, required):
>for letter in required:
>
On Mon, Jan 19, 2009 at 4:18 AM, jammy007 pp wrote:
> guys , i need immediate help on creating a simple tictactoe game .
>
> i read micheal dawson's book but didnt quiet get it .
>
> please help .
>
> thanks .
>
> jammy
The purpose of homework is that you figure it out for yourself and
learn som
On Mon, Jan 19, 2009 at 4:18 AM, jammy007 pp wrote:
> guys , i need immediate help on creating a simple tictactoe game .
>
> i read micheal dawson's book but didnt quiet get it .
>
> please help .
>
> thanks .
>
> jammy
Python Programming for the Absolute Beginner 2E
by Michael Dawson has the BES
Le Mon, 19 Jan 2009 01:18:41 -0800 (PST),
jammy007 pp a écrit :
> guys , i need immediate help on creating a simple tictactoe game .
>
> i read micheal dawson's book but didnt quiet get it .
>
> please help .
>
> thanks .
>
> jammy
>
>
>
>
try googling:
"software developpment compa
"Alan Gauld" wrote
If you already know Java, even a little bit then my tutorial will be
too basic for you.
I'd try the Byte of Python website/book.
Actually I meant the dive into python website/book.
Not that there's anything wrong with "Byte of" either, but "Dive In"
seems more appropria
On Sat, Jan 17, 2009 at 10:21 PM, Ian Egland wrote:
> In regards to learning python, I've found that after I get somewhat-familiar
> with a language, I want a programming problem to solve with what I've
> learned. While learning Java, http://www.javabat.com has been my best
> friend. (That is, as
"Ian Egland" wrote
learned. While learning Java, http://www.javabat.com has been my
best
friend. (That is, as close to a best friend as programming website
can be.)
Is there something like this for Java? Is one in the works?
If you already know Java, even a little bit then my tutorial will
On Sat, Jan 17, 2009 at 10:21 PM, Ian Egland wrote:
> I have looked at a couple tutorials and whipped this up. However, attempting
> to run it in IDLE results in a syntax error leaving my elif highlighted in
> red. What's wrong? I've looked at the code and can't find any syntax errors-
> though I'
"Brian van den Broek" wrote
I'll have him verify all steps again and then call `gremlins'.
One last thing to try is to get him to send a screen shot with the
error message showing. That will prove that he is using the right
type of console, typing the right command and reporting the
righ
Kent Johnson said unto the world at 15/01/09 12:33 PM:
On Thu, Jan 15, 2009 at 11:48 AM, Brian van den Broek
wrote:
The (recognized by me as) relevant bits of output are:
Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program
Files\texlive\2008\bin\win32;C:\Python26
PATHEXT=.CO
"Brian van den Broek" wrote
The (recognized by me as) relevant bits of output are:
Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program
Files\texlive\2008\bin\win32;C:\Python26
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
That looks OK. Puzzling!
Scraping th
On Thu, Jan 15, 2009 at 8:48 AM, Brian van den Broek
wrote:
>
> The (recognized by me as) relevant bits of output are:
> Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program
> Files\texlive\2008\bin\win32;C:\Python26
> PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
>
>
On Thu, Jan 15, 2009 at 9:35 AM, Dj Gilcrease wrote:
> if he just needs to run python scripts you just need to type the
> script name (preferably from the directory it is in)
>
> eg: C:\Path\To\App>app_name.py
>
> and it will run
>
By default, and on most people's machines, not true. You can do
if he just needs to run python scripts you just need to type the
script name (preferably from the directory it is in)
eg: C:\Path\To\App>app_name.py
and it will run
Also if you have changed the enviromental variables, you need to close
the command prompt and re-open it on windows since it does n
On Thu, Jan 15, 2009 at 11:48 AM, Brian van den Broek
wrote:
> The (recognized by me as) relevant bits of output are:
> Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program
> Files\texlive\2008\bin\win32;C:\Python26
> PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
>
>
Brian van den Broek said unto the world at 15/01/09 11:27 AM:
Alan Gauld said unto the world at 14/01/09 07:34 PM:
"Brian van den Broek" wrote
DOS prompt and replies including Alan's suggestion to get a text file
dump of environment variables.>
With the full path, python loads as expecte
Alan Gauld said unto the world at 14/01/09 07:34 PM:
"Brian van den Broek" wrote
icon for Idle launching as expected. When run from IDLE, `print
sys.executable' yields `C:\\Python26\\pythonw.exe'.
He reports that C:\Python26 contains both python.exe and pythonw.exe.
I've had him add the tex
"Marc Tompkins" wrote
- Also as wesley said, there MAY BE two separate PATHs - in my
experience,
the user-level one is usually empty and can be deleted to avoid
confusion.
If it's _not_ empty, it's usually by mistake...
It should be used where multiple users use a single machine and they
"Brian van den Broek" wrote
icon for Idle launching as expected. When run from IDLE, `print
sys.executable' yields `C:\\Python26\\pythonw.exe'.
He reports that C:\Python26 contains both python.exe and
pythonw.exe.
I've had him add the text `;C:\Python26' (without quotes) to the end
of his
On Wed, Jan 14, 2009 at 12:09 PM, wesley chun wrote:
>
> i fully agree with kent's comments/suggestions. you appeared to have
> them do the right thing. fwiw, the only time i run into that error
> after doing the same thing as you is that i'm trying that command in
> an already-opened command win
On Wed, Jan 14, 2009 at 12:01 PM, Kent Johnson wrote:
> On Wed, Jan 14, 2009 at 2:36 PM, Brian van den Broek
> wrote:
>>
>> He's got python 2.6.1 installed as evidenced by the Startbar program
>> icon for Idle launching as expected. When run from IDLE, `print
>> sys.executable' yields `C:\\Python
On Wed, Jan 14, 2009 at 2:36 PM, Brian van den Broek
wrote:
> Hi all,
>
> I'm trying, via email, to help a friend set up python on his Windows
> XP computer. I've been strictly linux for some time now, and don't
> have a Windows machine on which to investigate. We've hit a problem,
> and I'd appre
"rev pacce" wrote
I have no expierence using python.
I was following a tutorial and i kept getting a syntax error.
it was >>> print "hello world!" hello world was not coming up
OK, I guess that you tried typing the >>> howerver that bit
should be produced by the Python interpreter. You n
On Sun, 2009-01-11 at 14:01 -0800, rev pacce wrote:
> I have no expierence using python. I was following a tutorial and i
> kept getting a syntax error. it was >>> print "hello world!" hello
> world was not coming up underneath it.. i tried to run the module but
> that didnt work either.
>
> __
Saad Javed wrote:
The bold was intentional. I was trying to get a shell command (wvdial)
to run when a button is pressed. The error I get is:
Traceback (most recent call last):
File "testgui.py", line 26, in
testgui = TestGui()
File "testgui.py", line 19, in __init__
self.connect(d
I implemented a dial function and passed it to the QtCore.SLOT(), which
worked fine. Thanks everyone!
On Sat, Jan 3, 2009 at 10:33 PM, Kent Johnson wrote:
> On Sat, Jan 3, 2009 at 11:39 AM, Saad Javed wrote:
> > The bold was intentional. I was trying to get a shell command (wvdial) to
> > run w
On Sat, Jan 3, 2009 at 12:28 PM, Alan Gauld wrote:
> I think the SIGNAL('clicked()') bit is probably supposed to be:
>
> SIGNAL('clicked')
I think the parens are correct, see
http://docs.huihoo.com/pyqt/pyqt4.html#id10
Kent
___
Tutor maillist - Tuto
On Sat, Jan 3, 2009 at 11:39 AM, Saad Javed wrote:
> The bold was intentional. I was trying to get a shell command (wvdial) to
> run when a button is pressed. The error I get is:
>
> Traceback (most recent call last):
> File "testgui.py", line 26, in
> testgui = TestGui()
> File "testgui.
"Saad Javed" wrote
self.connect(dial, QtCore.SIGNAL('clicked()'), QtGui.qApp,
QtCore.SLOT(os.system('wvdial')))
TypeError: argument 1 of SLOT() has an invalid type
Was that helpful?
Yes, it confirms my earlier email that you should probably quote
the argument to SLOT()
Alan G.
__
"Saad Javed" wrote
I'm trying to create a simple GUI using pyqt4 in which pressing a
button
causes execution of a system command. Here's the code, please help
me out. I
can't figure out whats wrong. Thanks
Caveat: I have never used Qt in my life so this is based on guesswork
and experience
The bold was intentional. I was trying to get a shell command (wvdial) to
run when a button is pressed. The error I get is:
Traceback (most recent call last):
File "testgui.py", line 26, in
testgui = TestGui()
File "testgui.py", line 19, in __init__
self.connect(dial, QtCore.SIGNAL('c
Saad Javed wrote:
Hi Tutors,
Hi and welcome to the tutor list. We can help you better if you tell us
what the problem is. What did you expect? What did you get?
Most of us don't have the time or energy to read code when we don't
know what we are looking for.
Some of your code is bold. Why?
Thank you, thank you thank you! I'm now well on my way to solving my 35th
problem!! The wiki is fantastic, I thought "of course - I should have known
that!" It's easy when you know how.
Thanks again, especially for the prompt replies
2008/12/24 bob gailer
> Kent Johnson wrote:
>
>> On Tue, Dec 2
Kent Johnson wrote:
On Tue, Dec 23, 2008 at 8:20 PM, col speed wrote:
I've written a "division" function that gives more decimal places than the
one already in python. What my poor old brain can't work out is how to find
a "recurring cycle" which isn't disastrously complicated (as the cycle
On Tue, Dec 23, 2008 at 8:20 PM, col speed wrote:
> I've written a "division" function that gives more decimal places than the
> one already in python. What my poor old brain can't work out is how to find
> a "recurring cycle" which isn't disastrously complicated (as the cycle
> doesn't always in
"moham ilias" wrote in message
news:74b58e470812230730n4c3c5d1eg9f44a87b1bf9...@mail.gmail.com...
can anybody help me to get the example codes for some existing
python
projects. pls help in this regard
For simple examples try the Useless Python web site.
In particular check out the link t
On Tue, Dec 23, 2008 at 10:30 AM, moham ilias wrote:
> can anybody help me to get the example codes for some existing python
> projects. pls help in this regard
I'm not sure I understand your question. Do you want examples to look at?
Most of the Python standard library is written in Python so t
On Thu, Dec 4, 2008 at 11:38 AM, Jörg Wölke <[EMAIL PROTECTED]> wrote:
> #!/usr/bin/env python
>
> l=1*[1]
> for i in range(2,len(l)):
>if l[i] == 1:
> print i
> for j in range(i+1,len(l)):
> if j%i == 0:
for j in range(2*i, len(l), i):
would be much faster
* Richard Lovely <[EMAIL PROTECTED]> [081123 11:35]:
> I've tried a the sieve of erath-whatever as in test_generator,
> implemented using itertools functions, but it hit max recusion depth
> somewhere before 1000 primes, and I'm after millions of primes.
I found an old implementation for some exer
On Wed, Nov 19, 2008 at 8:13 AM, Richard Lovely
<[EMAIL PROTECTED]> wrote:
> Please don't suggest changing languages. I like python. Although if
> you want to write an extension for me, and provide the source and a
> makefile, please feel free. I have a MinGW install that's doing
> nothing. (Just
On a small side note, the docs say array.array is supposed to be
efficient. Testing has shown in this function, a list is faster (at
least for x<10). A set is faster still - at least over the same
range on my computer,, but you can't guarantee ordering, which makes
it inconsistent - an
On Wed, 19 Nov 2008 13:13:18 +, Richard Lovely wrote:
> I'm pretty new to code optimisation, so I thought I'd ask you all for
> advice.
>
> I'm making an iterative prime number generator. This is what I've got so
> far:
>
> Code: Select all
> import math, array
>
> def count2(start_at=0):
>
On Wed, Nov 19, 2008 at 8:13 AM, Richard Lovely
<[EMAIL PROTECTED]> wrote:
> I'm pretty new to code optimisation, so I thought I'd ask you all for advice.
>
> I'm making an iterative prime number generator.
You might be interested in this recipe and discussion:
http://code.activestate.com/recipes
On Mon, Oct 6, 2008 at 5:37 PM, Deitemeyer, Adam R
<[EMAIL PROTECTED]> wrote:
> Hello,
>
> I'm a beginner Python user and I have simple python issue I can't seem to
> solve. I want to do a truth test on a string to see if a another string is
> contained within it. I found that typically the re mo
2008/10/7 Deitemeyer, Adam R <[EMAIL PROTECTED]>:
> I'm a beginner Python user and I have simple python issue I can't seem to
> solve. I want to do a truth test on a string to see if a another string is
> contained within it. I found that typically the re module has the methods
> to accomplish th
Well, I know it doesn't repro with python 2.5 on ubuntu 8.04.
-Wayne
On Fri, Sep 19, 2008 at 4:49 AM, Stephen McInerney
<[EMAIL PROTECTED]>wrote:
> Could anyone help reproing this minor IDLE bug?
> http://bugs.python.org/issue3841
> I found it on Windows Vista with Python 2.5 / IDLE 1.2.2.
> Othe
Those worked for me...thanks again!!!
On Thu, Sep 4, 2008 at 3:26 PM, Kent Johnson <[EMAIL PROTECTED]> wrote:
> On Thu, Sep 4, 2008 at 4:56 PM, Spencer Parker <[EMAIL PROTECTED]>
> wrote:
> > I have a script that is taking a directory list, the script then splits
> the
> > name up by the hyphens
On Thu, Sep 4, 2008 at 4:56 PM, Spencer Parker <[EMAIL PROTECTED]> wrote:
> I have a script that is taking a directory list, the script then splits the
> name up by the hyphens in the name. The first part of the name should be a
> number, but it isn't always a number. Is there a way to say: if it
try and convert the first value in the split list to a int (or float), if
that works then post the value.
if it throws an exception (ValueError) then catch that and pass, or do
whatever else needs doing with the listing.
def postData(inputData):
fields=inputData.split("-")
try:
n
Rick Pasotto wrote:
I have a dictionary that looks like: d = {k:[v1,[v2,v3,v4]]}
v1,v2,v3,v4 are integers.
I want to print the dictionary sorted by v1, high to low.
sorted(d,operator.itemgetter(0),reverse=True)
You need to pass a compare function in... try
for ii in sorted(d,lambda ii,jj: c
On 8/17/08, Rick Pasotto <[EMAIL PROTECTED]> wrote:
> I have a dictionary that looks like: d = {k:[v1,[v2,v3,v4]]}
>
> v1,v2,v3,v4 are integers.
>
> I want to print the dictionary sorted by v1, high to low.
Do you want just the keys, or the key/value pairs, or what?
> sorted(d,operator.itemgetter
Norman Khine wrote:
Hi,
Appologies, there was a typo, in that the first line is:
['1'] ['a1', 'a2', 'a2', 'a2'] [1, 1, 2, 4]
Yes -- that helps.
So, working from your xml samples, by doing something like:
responses = [ [a,b,c] for a,b,c in responseAnalysisGenerator ]
you can end up with resp
Hi,
Appologies, there was a typo, in that the first line is:
['1'] ['a1', 'a2', 'a2', 'a2'] [1, 1, 2, 4]
The way the first line relates to the survey is such that, it looks at
the response.xml file and returns what the individual user has
submitted.
So that:
['1'] ['a1', 'a2', 'a2', 'a2'] [1, 1
Norman Khine wrote:
Hello,
I am writing a poll application, which has two XML files:
Is this entire question consistent? I ask because when you get to
asking your question below, it sounds like you're trying to tie together
two outputs:
> This returns:
> ['1'] ['1', '2', '2', '2'] [1, 1
"Dong Li" <[EMAIL PROTECTED]> wrote
If I want to create a text user interface for my application, is
there
any existed module to facilitate such building?
Yes, Python includes the cmd module which is a framework
for a menu driven command line. It is very like the help system
that Python uses
Am 04.07.2008 08:33, Dong Li schrieb:
Hi, everyone
If I want to create a text user interface for my application, is there
any existed module to facilitate such building?
Yes, there is curses:
http://docs.python.org/lib/module-curses.html
http://www.amk.ca/python/howto/curses/
HTH,
Wolfram
> I'd like to learn the language by writing some simple programs rather than
> keep reading books. My first program will convert certain uni-code characters
> (let's say UTF-8) in an RTF file format based on a certain mapping
> in another RTF file that is called a "RTF Control file".
> :
> The
Chien Nguyen wrote:
Hi All,
I am a newbie to Python. I just did some readings on the web
and got some basic understanding about the language. I'd like
to learn the language by writing some simple programs rather than
keep reading books. My first program will convert certain uni-code
characters
On Fri, Jun 20, 2008 at 12:46 PM, Chien Nguyen <[EMAIL PROTECTED]> wrote:
> Hi All,
> I am a newbie to Python. I just did some readings on the web
> and got some basic understanding about the language. I'd like
> to learn the language by writing some simple programs rather than
> keep reading books
Just like you'd add any other button on your web page
--
Evans
On Wed, Jun 11, 2008 at 8:49 AM, Mfana-boy Msibi <[EMAIL PROTECTED]>
wrote:
> How to add a delete button in your web page in Python
>
>
>
>
> __ Information from ESET NOD32 Antivirus, version of virus
> signature database 31
On Wed, May 14, 2008 at 3:45 AM, Mark <[EMAIL PROTECTED]> wrote:
> i want to set the keys of the user row as the keys of User self
> but i m not sure how to do it
>
> for i in self._user.keys():
> self[i]=self._user[i]
Should be
setattr(self, i, self._user[i])
> You ca
Hi Alan.
Thanks a lot. It worked
> --
>
> Message: 2
> Date: Sat, 26 Apr 2008 13:46:39 +0100
> From: "Alan Gauld" <[EMAIL PROTECTED]>
> Subject: Re: [Tutor] Help with Recurring Function
> To: tutor@python.org
> Messag
"Sanhita Mallick" <[EMAIL PROTECTED]> wrote
being calculated correctly as checked by the "print"
statement. But when we do
norm_ted = (2 * ted) / mag
It might be an integer division issue.
Try
norm_ted = (2*ted) / float(mag)
Just a thought...
--
Alan Gauld
Author of the Learn to
Hi Kent.
sum_norm_ted is sum over each i, and all j. That is
why it is initialize to zero at the beginning of each
i loop.
The inner loop IS running - which I checked by all the
print statements. The value of "ted" and "mag" ARE
being calculated correctly as checked by the "print"
statement. But
Sanhita Mallick wrote:
I am struggling with a simple recurring function
What is a recurring function? Do you mean looping?
Here is the script. T(i) are trees (as in graphs).
The program operates great, until the step where
norm_ted is calculated. Mysteriously norm_ted becomes
0, even though
Sanhita Mallick wrote:
Hi.
I am struggling with a simple recurring function, but
can't understand why this is happening. Please help.
Here is the script. T(i) are trees (as in graphs).
The program operates great, until the step where
norm_ted is calculated. Mysteriously norm_ted becomes
0, even
"Michael Kim" <[EMAIL PROTECTED]> wrote
> Hi I am having a really hard time making my tictactoe program work.
> I
> was wondering if you could could check it out and help me with the
> error. Thanks
Like to give us a clue as to what the error is?
And include the error message if there is one p
On 4/17/2008 3:40 AM, Michael Kim wrote:
> Hi I am having a really hard time making my tictactoe program work. I
> was wondering if you could could check it out and help me with the
> error. Thanks
Heh.
First, there are two obvious indentation errors you can find yourself.
This may be a bypr
Michael Kim wrote:
> Hi I am having a really hard time making my tictactoe program work. I
> was wondering if you could could check it out and help me with the
> error. Thanks
>
As Kent pointed out, we need to see the error you are getting in order
to help. That usually shows up as a trace
Michael Kim wrote:
> Hi I am having a really hard time making my tictactoe program work. I
> was wondering if you could could check it out and help me with the
> error. Thanks
What is the error?
Kent
___
Tutor maillist - Tutor@python.org
http://ma
Thanks to all. My posts do show up. Now how to get them sent to me???
--
Bob Gailer
919-636-4239 Chapel Hill, NC
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Thanks all for the posts,
I guess I'm thinking in 'matrices' and in a matlab syntax. So I was trying
to get the third element of a list of lists, or lists in a dictionay in
syntax like matlab (yes, I should be using numpy or scipy).
Anyway, Alan's final suggestion (and everyone else's) has helped
On Fri, Mar 28, 2008 at 12:50 AM, Amin Han <[EMAIL PROTECTED]> wrote:
> Hi, I'm currently a novice at Python, and I need help creating the
> following program...
>
> # Write a program that asks the user to enter a package number and the
> total number of hours spent online that month (you may as
Hint: When you want help with your homework, you should first try to
program something. Pasting the requirements to this mailing list will
not help you. Homeworks are there so that YOU learn something. Not that
you can prove that you are capable to find someone that does it for you.
Andreas
Am Fr
Olexander wrote:
> Hello,
>
> please could you help me with input processing for olympiad problems.
Do you know how to read and write files? This is covered in every Python
book and tutorial.
What have you tried? What problems are you having?
> I also wonder how to output several integers in o
"Elliot Silvers" <[EMAIL PROTECTED]> wrote
> I am as new as you can get to Python. I have just learned
> how to save my work (very simple work of course).
> I created a folder on C:\ (in this case C:\Elliot) for my work.
> I am able to use the cmd prompt to run it
Congratulations. You should
This is Windows I presume?
Try:
cd\python25
python C:\Elliot\filename.py
But for windows you shouldn't have to. You can just double-click the file.
On the other hand, if you mean 'import' as it means in the context of the
actual python language, then you would put the line "import filename" at
PyProg PyProg wrote:
> Hello,
>
> I have a little problem, I have two lists:
>
a=[1, 2, 3, 4, 5, 6]
b=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
>
> ... and I want to obtain:
>
[('a', 1), ('b', 2), ('c', 3), ('d', 4), ('e', 5), ('f', 6), ('g',
> 1), ('h', 2), ('i', 3), ('
Assuming that len(b) > len(a):
>>> zip(itertools.cycle(a), b)
[(1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e'), (6, 'f'), (1, 'g'), (2,
'h'), (3, 'i'), (4, 'j')]
Andreas
Am Dienstag, den 18.03.2008, 16:23 +0100 schrieb PyProg PyProg:
> Hello,
>
> I have a little problem, I have two lists:
>
"Ole Henning Jensen" <[EMAIL PROTECTED]> wrote
> What you need to do is loop all the way through your list and then
> only
> do something to every third element in the list
That's not quite what the OP asked for, he wanted the third
element from every sublist in the master list
> This is an exa
"washakie" <[EMAIL PROTECTED]> wrote
> Could someone please explain 'slices' also for dictionaries?
So far as I know slices don;t work for dictionaries directly -
dictionaries
don't have the concept of order. However you could get a list of
keys and apply a slice to that, although I'm not sure
bob gailer wrote:
> washakie wrote:
>
>> Could someone please explain 'slices' also for dictionaries?
>>
>> basically, I'd like to know how you would call every 3rd element in a list
>> of lists...
>>
Call? Do you mean that these elements are callable objects (e.g.
functions) which you wa
washakie wrote:
> Could someone please explain 'slices' also for dictionaries?
>
> basically, I'd like to know how you would call every 3rd element in a list
> of lists...
>
> My logic says: ThirdElems=List[:][2]
>
> Which to me reads, for every item in List (which are lists), return the
> third i
> Could someone please explain 'slices' also for dictionaries?
>
> basically, I'd like to know how you would call every 3rd element in a list
> of lists...
>
> My logic says: ThirdElems=List[:][2]
>
What this does is, just assign the 3 value of List to the variable.
look at this way, step by st
What you probably want is:
[elem_list[2] for elem_list in List]
If you are not sure that the list have at least three elements, you can
use something like this:
[(elem_list + [None, None, None])[2] for elem_list in List]
Which will use None as a default value.
Andreas
Am Dienstag, den 04.03.2
"Krystle Scott" <[EMAIL PROTECTED]> wrote
>i need to write an algorithm for computing square roots.
We don;t do homework here but we can help with specific
questions and to resolve errors.
> import math
>
> def main ():
> print " This program computes approximate square roots using
> Newt
Krystle Scott wrote:
> i need to write an algorithm for computing square roots.
> so far I have
This sounds like a class exercise. I think we can help you with
Python questions, but you'll need to do the part that is directly
related to your homework on your own.
> import math
>
> def main ():
bill.wu wrote:
>
> i am new guy.
> i ask a easy question.
There is no need to ask twice.
Please post messages in plain-text, not HTML.
Kent
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
"bill.wu" <[EMAIL PROTECTED]> wrote
> i ask a easy question.
>
> why the first one have"x",the second one
> doesn't have "x". what is different?
The first is using x as the name of a parameter
of the function and is only used inside the function.
The second one takes no parameter and relies
bill.wu gmail.com> writes:
>
>
>
> i am new guy.
> i ask a easy question.
>
> why the first one have"x",the second one doesn't have "x". what
> is different? when write "x",when don't write "x".
>
> in my point,the second one don't def variable.
>
>
Variable scope. By declaring the
Chris Fuller wrote:
> This is a good case for recursion. My solution is in two steps.
> Here is the code:
>
> def recursion_is_your_friend(l):
>if len(l) == 1:
> return l
>else:
> return [ (i, recursion_is_your_friend(l[1:])) for i in l[0] ]
>
> l = recursion_is_your_friend([[
This is a good case for recursion. My solution is in two steps. A
straightforward application of recursion (I was casting about semi-randomly)
yields a attractive tree structure:
root
a b
c d e c de
f f f f ff
g h
Andrew Critchley wrote:
> I recently downloaded the newer version of python, the 2.5.1 one, and
> when ever i try to make an input what ever i type into the brackets
> appears on the next line and when i try to add the next line it
> carries on from the input,This is what happens:
>
> I type t
"Luis N" <[EMAIL PROTECTED]> wrote
> I'd like the below to be a single line if possible.
Beware compression for the sake of it. However we can simplify
a bit using divmod()
> hours = metrics.totaltime/360
> minutes = (metrics.totaltime - 360*hours)/6
> seconds = (metrics.totaltime -
Greetings,
On 11/3/07, John <[EMAIL PROTECTED]> wrote:
> Good point, I think that goes for learning a programming language in general
> ;) Find one that works, and master it...
>
> I'm starting to put together the picture of what a Python installation is,
> but I have to admit, when you work on mu
1101 - 1200 of 1591 matches
Mail list logo