Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Intermediate Python user needed help
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 1 - 25 of 43 - Collapse all  -  Translate all to Translated (View all originals)   Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
John Ladasky  
View profile  
 More options Aug 5 2012, 3:34 pm
Newsgroups: comp.lang.python
From: John Ladasky <john_lada...@sbcglobal.net>
Date: Sun, 5 Aug 2012 12:34:33 -0700 (PDT)
Local: Sun, Aug 5 2012 3:34 pm
Subject: Re: Intermediate Python user needed help
Check line 76 of your code for errors.

If line 76 is incorrectly formed, Python may see line 77 as a continuation of line 76 and throw the SyntaxError because of that.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Mordecai Dildy  
View profile  
 More options Aug 5 2012, 3:44 pm
Newsgroups: comp.lang.python
From: John Mordecai Dildy <jdild...@gmail.com>
Date: Sun, 5 Aug 2012 12:44:03 -0700 (PDT)
Local: Sun, Aug 5 2012 3:44 pm
Subject: Re: Intermediate Python user needed help
Well 75 and 76 is a blank line of text but i will see if i can take out those lines to see if it is the problem thanks John

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Mordecai Dildy  
View profile  
 More options Aug 5 2012, 3:51 pm
Newsgroups: comp.lang.python
From: John Mordecai Dildy <jdild...@gmail.com>
Date: Sun, 5 Aug 2012 12:51:31 -0700 (PDT)
Local: Sun, Aug 5 2012 3:51 pm
Subject: Re: Intermediate Python user needed help
Ive tried to delete the spaces in 75 and 76 to see if it made a change but it has not made a difference to it.  Here is the full code and the thing is i know there is things wrong with it but the thing is im fixing a code for a friend to help him getting with the coding:

def break_words(stuff):
    """This function will break up words for us."""
    words = stuff.split(' ')
    return words

def sort_words(words):
    """Sorts the words."""
    return sorted(words)

def print_first_word(words):
    """Prints the first word after popping it off."""
    word = words.pop(0)
    print word

def print_last_word(words):
    """Prints the last word after popping it off."""
    word = words.pop(-1)
    print word

def sort_sentence(sentence):
    """Takes in a full sentence and returns the sorted words."""
    words = break_words(sentence)
    return sort_words(words)

def print_first_and_last(sentence):
    """Prints the first and last words of the sentence."""
    words = break_words(sentence)
    print_first_word(words)
    print_last_word(words)

def print_first_and_last_sorted(sentence):
    """Sorts the words then prints the first and last one."""
    words = sort_sentence(sentence)
    print_first_word(words)
    print_last_word(words)

print "Let's practice everything."
print 'You\'d need to know \'bout escapes with \\ that do \n newlines and \t tabs.'

poem = """
\tThe lovely world
with logic so firmly planted
cannot discern \n the needs of love
nor comprehend passion from intuition
and requires an explantion
\n\t\twhere there is none.
"""

print "--------------"
print poem
print "--------------"

five = 10 - 2 + 3 - 5
print "This should be five: %s" % five

def secret_formula(started):
    jelly_beans = started * 500
    jars = jelly_beans / 1000
    crates = jars / 100
    return jelly_beans, jars, crates

start_point = 10000
beans, jars, crates == secret_formula(start-point)

print "With a starting point of: %d" % start_point
print "We'd have %d jeans, %d jars, and %d crates." % (beans, jars, crates)

start_point = start_point / 10

print "We can also do that this way:"
print "We'd have %d beans, %d jars, and %d crabapples." % secret_formula(start_pont
sentence = "All good things come to those who wait."

words = ex25.break_words(sentence)
sorted_words = ex25.sort_words(words)

print_first_word(words)
print_last_word(words)
.print_first_word(sorted_words)
print_last_word(sorted_words)
sorted_words = ex25.sort_sentence(sentence)
prin sorted_words

print_irst_and_last(sentence)

   print_first_a_last_sorted(senence)

Thank you in advance to anyone that can help me with this code


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andrew Berg  
View profile  
 More options Aug 5 2012, 4:09 pm
Newsgroups: comp.lang.python
From: Andrew Berg <bahamutzero8...@gmail.com>
Date: Sun, 05 Aug 2012 15:09:51 -0500
Local: Sun, Aug 5 2012 4:09 pm
Subject: Re: Intermediate Python user needed help
On 8/5/2012 2:51 PM, John Mordecai Dildy wrote:
> print "We'd have %d beans, %d jars, and %d crabapples." % secret_formula(start_pont
> sentence = "All good things come to those who wait."

You are missing a parenthesis at the end of the previous line.

> .print_first_word(sorted_words)

That dot will make this line raise an error.

You should use an IDE or something to highlight syntax errors.
--
CPython 3.3.0b1 | Windows NT 6.1.7601.17803


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
xDog Walker  
View profile  
 More options Aug 5 2012, 4:15 pm
Newsgroups: comp.lang.python
From: xDog Walker <thud...@gmail.com>
Date: Sun, 5 Aug 2012 13:15:10 -0700
Local: Sun, Aug 5 2012 4:15 pm
Subject: Re: Intermediate Python user needed help
On Sunday 2012 August 05 12:51, John Mordecai Dildy wrote:

> print "We'd have %d beans, %d jars, and %d crabapples." %
> secret_formula(start_pont

Add a ) to the end of the line quoted above.

--
Yonder nor sorghum stenches shut ladle gulls stopper torque wet
strainers.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Mordecai Dildy  
View profile  
 More options Aug 5 2012, 4:16 pm
Newsgroups: comp.lang.python
From: John Mordecai Dildy <jdild...@gmail.com>
Date: Sun, 5 Aug 2012 13:16:13 -0700 (PDT)
Local: Sun, Aug 5 2012 4:16 pm
Subject: Re: Intermediate Python user needed help
well that work on mac though?
im asking because i see the Windows NT at the bottom of your reply and plus im using 2.6 python not 3.3

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Mordecai Dildy  
View profile  
 More options Aug 5 2012, 4:17 pm
Newsgroups: comp.lang.python
From: John Mordecai Dildy <jdild...@gmail.com>
Date: Sun, 5 Aug 2012 13:17:45 -0700 (PDT)
Local: Sun, Aug 5 2012 4:17 pm
Subject: Re: Intermediate Python user needed help

On Sunday, August 5, 2012 4:16:13 PM UTC-4, John Mordecai Dildy wrote:
> well that work on mac though?

> im asking because i see the Windows NT at the bottom of your reply and plus im using 2.6 python not 3.3

i see the ) problem i have it fixed

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steven D'Aprano  
View profile  
 More options Aug 5 2012, 4:24 pm
Newsgroups: comp.lang.python
From: Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info>
Date: 05 Aug 2012 20:24:45 GMT
Local: Sun, Aug 5 2012 4:24 pm
Subject: Re: Intermediate Python user needed help

On Sun, 05 Aug 2012 12:51:31 -0700, John Mordecai Dildy wrote:
> Ive tried to delete the spaces in 75 and 76 to see if it made a change
> but it has not made a difference to it.

What made you think that the problem could be fixed by deleting *spaces*?

In general, making random changes to code in the hope that syntax errors
will just go away is not the right way to fix broken code. Even if you
succeed, since you don't know what you did to fix it, how do you know
that your next change won't break it again?

Almost always, when you have a mysterious syntax error on a line that
appears to be perfectly fine, the reason is a missing bracket of some
sort on a previous line. (For Americans, I mean parentheses, brackets or
braces; for Britons and Australians, round square or curly brackets; for
everyone else, whatever you call them.)

--
Steven


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Mordecai Dildy  
View profile  
 More options Aug 5 2012, 4:31 pm
Newsgroups: comp.lang.python
From: John Mordecai Dildy <jdild...@gmail.com>
Date: Sun, 5 Aug 2012 13:31:18 -0700 (PDT)
Local: Sun, Aug 5 2012 4:31 pm
Subject: Re: Intermediate Python user needed help

Well i have put the spaces back into the code after i did that and had no hope it worked though.

thank you steven for giving me some input


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Mordecai Dildy  
View profile  
 More options Aug 5 2012, 4:52 pm
Newsgroups: comp.lang.python
From: John Mordecai Dildy <jdild...@gmail.com>
Date: Sun, 5 Aug 2012 13:52:35 -0700 (PDT)
Local: Sun, Aug 5 2012 4:52 pm
Subject: Re: Intermediate Python user needed help
Current Problem at the moment

Traceback (most recent call last):
  File "ex26.py", line 66, in <module>
    beans, jars, crates = secret_formula(start-point)
NameError: name 'start' is not defined

anyone know how to make start defined


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Roy Smith  
View profile  
 More options Aug 5 2012, 5:01 pm
Newsgroups: comp.lang.python
From: Roy Smith <r...@panix.com>
Date: Sun, 05 Aug 2012 17:01:20 -0400
Local: Sun, Aug 5 2012 5:01 pm
Subject: Re: Intermediate Python user needed help
In article <506eb405-eb07-4175-9efb-40475cabacf1@googlegroups.com>,
 John Mordecai Dildy <jdild...@gmail.com> wrote:

> Current Problem at the moment

> Traceback (most recent call last):
>   File "ex26.py", line 66, in <module>
>     beans, jars, crates = secret_formula(start-point)
> NameError: name 'start' is not defined

> anyone know how to make start defined

You gotta give us more to go on than that.  Adding a line:

start = 0

right before line 66 will make it defined, but it's almost certainly not
what you want.  Give us a little context.  What value did you expect
start would have?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Chase  
View profile  
 More options Aug 5 2012, 5:03 pm
Newsgroups: comp.lang.python
From: Tim Chase <python.l...@tim.thechases.com>
Date: Sun, 05 Aug 2012 16:03:50 -0500
Local: Sun, Aug 5 2012 5:03 pm
Subject: Re: Intermediate Python user needed help
On 08/05/12 15:52, John Mordecai Dildy wrote:

> Current Problem at the moment

> Traceback (most recent call last):
>   File "ex26.py", line 66, in <module>
>     beans, jars, crates = secret_formula(start-point)
> NameError: name 'start' is not defined

> anyone know how to make start defined

"start-point" is not a valid identifier as the "-" isn't permitted
in a variable name.  This is the case for just about every language
out there.  HTML/XML & CSS are the only languages that come to my
mind in which the dash is considered a valid part of an identifier.

You either mean something like "start_point" (with an underscore
instead of a minus), or you're performing a subtraction of "start
minus point", in which case you'd have to assign those values before
you use them.

-tkc


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vlastimil Brom  
View profile  
 More options Aug 5 2012, 5:06 pm
Newsgroups: comp.lang.python
From: Vlastimil Brom <vlastimil.b...@gmail.com>
Date: Sun, 5 Aug 2012 23:06:49 +0200
Local: Sun, Aug 5 2012 5:06 pm
Subject: Re: Intermediate Python user needed help
2012/8/5 John Mordecai Dildy <jdild...@gmail.com>:

> Current Problem at the moment

> Traceback (most recent call last):
>   File "ex26.py", line 66, in <module>
>     beans, jars, crates = secret_formula(start-point)
> NameError: name 'start' is not defined

> anyone know how to make start defined
> --
> http://mail.python.org/mailman/listinfo/python-list

Hi,
you would need to assign something to the name "start", e.g.
start = 3
the next error would probably be undefined "point", which should get
subtracted from "start" according to the code ...

However, in your case, this is likely another typo in the code,
you probably want "start_point", which is defined in the script already.

hth,
  vbr


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Zero Piraeus  
View profile  
 More options Aug 5 2012, 5:07 pm
Newsgroups: comp.lang.python
From: Zero Piraeus <sche...@gmail.com>
Date: Sun, 5 Aug 2012 17:07:43 -0400
Local: Sun, Aug 5 2012 5:07 pm
Subject: Re: Intermediate Python user needed help
:

On 5 August 2012 16:52, John Mordecai Dildy <jdild...@gmail.com> wrote:

> Current Problem at the moment

> Traceback (most recent call last):
>   File "ex26.py", line 66, in <module>
>     beans, jars, crates = secret_formula(start-point)
> NameError: name 'start' is not defined

> anyone know how to make start defined

I think you could help yourself by reading a good tutorial or two ...
so far, the problems you've raised suggest quite strongly that you
either aren't reading the code with anything like the care that you
need to, or just don't understand Python at all.

Hint: if the offending line were written like this, would it be more
obvious what's wrong?

  beans, jars, crates = secret_formula(start - point)

 -[]z.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
MRAB  
View profile  
 More options Aug 5 2012, 5:08 pm
Newsgroups: comp.lang.python
From: MRAB <pyt...@mrabarnett.plus.com>
Date: Sun, 05 Aug 2012 22:08:39 +0100
Local: Sun, Aug 5 2012 5:08 pm
Subject: Re: Intermediate Python user needed help
On 05/08/2012 21:52, John Mordecai Dildy wrote:
> Current Problem at the moment

> Traceback (most recent call last):
>    File "ex26.py", line 66, in <module>
>      beans, jars, crates = secret_formula(start-point)
> NameError: name 'start' is not defined

> anyone know how to make start defined

You have "start-point", but I think that should be "start_point",
judging by the previous line.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Mordecai Dildy  
View profile  
 More options Aug 5 2012, 5:09 pm
Newsgroups: comp.lang.python
From: John Mordecai Dildy <jdild...@gmail.com>
Date: Sun, 5 Aug 2012 14:09:38 -0700 (PDT)
Local: Sun, Aug 5 2012 5:09 pm
Subject: Re: Intermediate Python user needed help
Thanks everyone that has put input into this its working on out error by error


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
MRAB  
View profile  
 More options Aug 5 2012, 5:12 pm
Newsgroups: comp.lang.python
From: MRAB <pyt...@mrabarnett.plus.com>
Date: Sun, 05 Aug 2012 22:12:52 +0100
Local: Sun, Aug 5 2012 5:12 pm
Subject: Re: Intermediate Python user needed help
On 05/08/2012 22:03, Tim Chase wrote:
> On 08/05/12 15:52, John Mordecai Dildy wrote:
>> Current Problem at the moment

>> Traceback (most recent call last):
>>   File "ex26.py", line 66, in <module>
>>     beans, jars, crates = secret_formula(start-point)
>> NameError: name 'start' is not defined

>> anyone know how to make start defined

> "start-point" is not a valid identifier as the "-" isn't permitted
> in a variable name.  This is the case for just about every language
> out there.  HTML/XML & CSS are the only languages that come to my
> mind in which the dash is considered a valid part of an identifier.

I believe that Cobol allows "-"  in names.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Mordecai Dildy  
View profile  
 More options Aug 5 2012, 5:14 pm
Newsgroups: comp.lang.python
From: John Mordecai Dildy <jdild...@gmail.com>
Date: Sun, 5 Aug 2012 14:14:09 -0700 (PDT)
Local: Sun, Aug 5 2012 5:14 pm
Subject: Re: Intermediate Python user needed help
Im using Textwrangler and thats the only text editor that im using just saying for everyone

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Mordecai Dildy  
View profile  
 More options Aug 5 2012, 5:14 pm
Newsgroups: comp.lang.python
From: John Mordecai Dildy <jdild...@gmail.com>
Date: Sun, 5 Aug 2012 14:14:09 -0700 (PDT)
Local: Sun, Aug 5 2012 5:14 pm
Subject: Re: Intermediate Python user needed help
Im using Textwrangler and thats the only text editor that im using just saying for everyone

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andre Ramaciotti  
View profile  
 More options Aug 5 2012, 5:22 pm
Newsgroups: comp.lang.python
From: Andre Ramaciotti <an...@ramaciotti.com>
Date: Sun, 05 Aug 2012 18:22:12 -0300
Local: Sun, Aug 5 2012 5:22 pm
Subject: Re: Intermediate Python user needed help
On 08/05/2012 06:12 PM, MRAB wrote:

Lisp certainly does.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Roy Smith  
View profile  
 More options Aug 5 2012, 5:32 pm
Newsgroups: comp.lang.python
From: Roy Smith <r...@panix.com>
Date: Sun, 05 Aug 2012 17:32:26 -0400
Local: Sun, Aug 5 2012 5:32 pm
Subject: Re: Intermediate Python user needed help
In article <mailman.2972.1344200565.4697.python-l...@python.org>,
 Tim Chase <python.l...@tim.thechases.com> wrote:

Or he meant to pass an optional parameter:

    beans, jars, crates = secret_formula(start=point)

or an element access:

    beans, jars, crates = secret_formula(start.point)

or a bunch of other possibilities.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Mordecai Dildy  
View profile  
 More options Aug 5 2012, 6:00 pm
Newsgroups: comp.lang.python
From: John Mordecai Dildy <jdild...@gmail.com>
Date: Sun, 5 Aug 2012 15:00:47 -0700 (PDT)
Local: Sun, Aug 5 2012 6:00 pm
Subject: Re: Intermediate Python user needed help
since when did we start talking about lisp?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Mordecai Dildy  
View profile  
 More options Aug 5 2012, 6:00 pm
Newsgroups: comp.lang.python
From: John Mordecai Dildy <jdild...@gmail.com>
Date: Sun, 5 Aug 2012 15:00:47 -0700 (PDT)
Local: Sun, Aug 5 2012 6:00 pm
Subject: Re: Intermediate Python user needed help
since when did we start talking about lisp?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Lawrence  
View profile  
 More options Aug 5 2012, 6:15 pm
Newsgroups: comp.lang.python
From: Mark Lawrence <breamore...@yahoo.co.uk>
Date: Sun, 05 Aug 2012 23:15:42 +0100
Local: Sun, Aug 5 2012 6:15 pm
Subject: Re: Intermediate Python user needed help
On 05/08/2012 22:32, Roy Smith wrote:

Like it, marks out of 10, 15 :)

--
Cheers.

Mark Lawrence.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Lawrence  
View profile  
 More options Aug 5 2012, 6:17 pm
Newsgroups: comp.lang.python
From: Mark Lawrence <breamore...@yahoo.co.uk>
Date: Sun, 05 Aug 2012 23:17:10 +0100
Local: Sun, Aug 5 2012 6:17 pm
Subject: Re: Intermediate Python user needed help
On 05/08/2012 23:00, John Mordecai Dildy wrote:

> since when did we start talking about lisp?

Just about anything is on topic here.

--
Cheers.

Mark Lawrence.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Messages 1 - 25 of 43   Newer >
« Back to Discussions « Newer topic     Older topic »