FAQ
I don't understand what I'm doing wrong i've tried several different cases
for what i am doing here. Will someone please point my error out.

Thank you.


1 #!/bin/bash/python
2 import math
3 try:
4 x = int(input("Enter your number: "))
5 if( 0 > x | x > 2147483647):
6 raise Exception()
7 else:
8 end = 0
9 count = 0
10 count1 = x
11 counter = 0
12 print("end: ", end)
13 print("count: ", count)
14 print("count1: ", count1)
15 print("counter: ", counter
16
17 while (end == 0): #
<-------------------returns syntax error on this while statement
18 if(count < x):
19
20 sol = math.pow(count, 2) + math.pow(count1, 2)
21 count += 1
22 count1 -= 1
23 print("end: ", end)
24 print("count: ", count)
25 print("count1: ", count1)
26 print("counter: ", counter
27 if( sol == x):
28 counter += x
29 else:
30 end = 1
31 except Exception as ran:
32 print("Value not within range", ran)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110107/bfff85b5/attachment.html>

Search Discussions

  • Chris Rebert at Jan 8, 2011 at 5:28 am

    On Fri, Jan 7, 2011 at 9:18 PM, Garland Fulton wrote:
    I don't understand what I'm doing wrong i've tried several different cases
    for what i am doing here. Will someone please point my error out.
    Thank you.

    ??1 #!/bin/bash/python
    This shebang undoubtedly erroneous.
    ??5 ? ? if( 0 > x | x > 2147483647):
    One normally writes that using boolean "or" rather than the bitwise
    operator. Also, the parentheses are completely unnecessary visual
    clutter.
    ?15 ? ? ? ? print("counter: ", counter
    Where's the closing parenthesis?
    ?17 ? ? ? ? ? ? ? while (end == 0): ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?#
    <-------------------returns syntax error on this while statement
    Always include the exact error message + traceback in the future.

    Cheers,
    Chris
  • Ned Deily at Jan 8, 2011 at 5:28 am
    In article
    <AANLkTik2eii-mWHG-eH_xe9KfHiyLHyEfZpVm7yZgKEt at mail.gmail.com>,
    Garland Fulton wrote:
    I don't understand what I'm doing wrong i've tried several different cases
    for what i am doing here. Will someone please point my error out.
    15 print("counter: ", counter
    Missing ")" on line 15.

    --
    Ned Deily,
    nad at acm.org
  • Garland Fulton at Jan 8, 2011 at 5:46 am

    On Fri, Jan 7, 2011 at 8:28 PM, Ned Deily wrote:

    In article
    <AANLkTik2eii-mWHG-eH_xe9KfHiyLHyEfZpVm7yZgKEt at mail.gmail.com>,
    Garland Fulton wrote:
    I don't understand what I'm doing wrong i've tried several different cases
    for what i am doing here. Will someone please point my error out.
    15 print("counter: ", counter
    Missing ")" on line 15.

    --
    Ned Deily,
    nad at acm.org

    --
    http://mail.python.org/mailman/listinfo/python-list

    1 #!/bin/bash/python
    2 import math
    3 try:
    4 x = int(input("Enter your number: "))
    5 if 0 > x > 2147483647:
    6 raise Exception()
    7 else:
    8 end = 0
    9 count = 0
    10 count1 = x
    11 counter = 0
    12 print("end: ", end)
    13 print("count: ", count)
    14 print("count1: ", count1)
    15 print("counter: ", counter)
    16
    17 while end == 0: #
    <-------------------returns syntax error on this while statement
    18 if(count < x):
    19
    20 sol = math.pow(count, 2) + math.pow(count1, 2)
    21 count += 1
    22 count1 -= 1
    23 print("end: ", end)
    24 print("count: ", count)
    25 print("count1: ", count1)
    26 print("counter: ", counter)
    27 if sol == x:
    28 counter += x
    29 else:
    30 end = 1
    31 except Exception as ran:
    32 print("Value not within range", ran)


    File "blah.py", line 17
    while (end == 0): #
    <-------------------returns syntax error on this while statement
    ^
    IndentationError: unexpected indent

    Thank you and I'm sorry for the very blind question, it was because of the
    missing par-ends I have spent a while on this won't happen again. What is
    wrong with my shebang line?
    Thank you for the syntax tips!
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: <http://mail.python.org/pipermail/python-list/attachments/20110107/a3610e2d/attachment.html>
  • Chris Rebert at Jan 8, 2011 at 5:55 am
    On Fri, Jan 7, 2011 at 9:46 PM, Garland Fulton wrote:
    <snip>
    ??1 #!/bin/bash/python <snip>
    What is
    wrong with my shebang line?
    Its path is invalid (unless you're using a *very* weird system).
    /bin/bash is the bash shell executable; bash is completely unrelated
    to Python. Further, /bin/bash is a file, not a directory.

    The shebang for Python is normally one of the following:
    #!/usr/bin/env python
    #!/usr/bin/python

    Cheers,
    Chris
  • Garland Fulton at Jan 8, 2011 at 5:57 am

    On Fri, Jan 7, 2011 at 8:55 PM, Chris Rebert wrote:

    On Fri, Jan 7, 2011 at 9:46 PM, Garland Fulton wrote:
    <snip>
    1 #!/bin/bash/python <snip>
    What is
    wrong with my shebang line?
    Its path is invalid (unless you're using a *very* weird system).
    /bin/bash is the bash shell executable; bash is completely unrelated
    to Python. Further, /bin/bash is a file, not a directory.

    The shebang for Python is normally one of the following:
    #!/usr/bin/env python
    #!/usr/bin/python

    Cheers,
    Chris
    --
    http://blog.rebertia.com

    Great I have learned a ton and these questions will not arise again.
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: <http://mail.python.org/pipermail/python-list/attachments/20110107/b6593ba5/attachment.html>
  • Terry Reedy at Jan 8, 2011 at 11:04 am

    15 print("counter: ", counter
    16
    17 while (end == 0): #
    <-------------------returns syntax error on this while statement
    Among other responses, there is no indent after print.
    should be
    print()
    while x:
    #now indent
    --
    Terry Jan Reedy

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedJan 8, '11 at 5:18a
activeJan 8, '11 at 11:04a
posts7
users4
websitepython.org

People

Translate

site design / logo © 2022 Grokbase