Re: [Tutor] Request for help with code

2018-11-07 Thread Roger B. Atkins
Gmail: Click Compose (Upper Left corner)
Window opens. In lower right corner within the compose window, click
on the 3 stacked dots.
Select text only.
On Wed, Nov 7, 2018 at 1:39 AM Adam Eyring  wrote:
>
> When I post code with questions, I just copy and paste from Python IDLE
> 3.6. Colors are removed, but indentation is preserved.
>
> On Tue, Nov 6, 2018 at 6:59 PM Mats Wichmann  wrote:
>
> > On 11/6/18 4:36 PM, Joseph Gulizia wrote:
> > > Funny using a text editorand showed indented in my browser.
> >  Won't
> > > bother the list again.
> >
> > We don't want you to "not bother" us, just hoping to get things in a
> > state where we can actually help...
> >
> > here's what we end up seeing:
> >
> > https://www.mail-archive.com/tutor@python.org/msg79222.html
> > https://www.mail-archive.com/tutor@python.org/msg79225.html
> >
> > since unlike most other languages, indentation is a crucial part of the
> > syntax, we tend to grumble.
> >
> > there must be some solution... guys, do you know of any alternate way to
> > send a message to the list if a mail client isn't cooperating? or do we
> > have instructions for beating gmail into submission?  Obviously gmail is
> > a key part of the modern infrastructure despite its (ahem) misfeatures.
> >
> >
> > ___
> > Tutor maillist  -  Tutor@python.org
> > To unsubscribe or change subscription options:
> > https://mail.python.org/mailman/listinfo/tutor
> >
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Request for help with code

2018-11-07 Thread Adam Eyring
When I post code with questions, I just copy and paste from Python IDLE
3.6. Colors are removed, but indentation is preserved.

On Tue, Nov 6, 2018 at 6:59 PM Mats Wichmann  wrote:

> On 11/6/18 4:36 PM, Joseph Gulizia wrote:
> > Funny using a text editorand showed indented in my browser.
>  Won't
> > bother the list again.
>
> We don't want you to "not bother" us, just hoping to get things in a
> state where we can actually help...
>
> here's what we end up seeing:
>
> https://www.mail-archive.com/tutor@python.org/msg79222.html
> https://www.mail-archive.com/tutor@python.org/msg79225.html
>
> since unlike most other languages, indentation is a crucial part of the
> syntax, we tend to grumble.
>
> there must be some solution... guys, do you know of any alternate way to
> send a message to the list if a mail client isn't cooperating? or do we
> have instructions for beating gmail into submission?  Obviously gmail is
> a key part of the modern infrastructure despite its (ahem) misfeatures.
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Request for help with code

2018-11-06 Thread Steven D'Aprano
On Tue, Nov 06, 2018 at 06:32:25PM -0500, Joel Goldstick wrote:

[snip nearly seven screens of quoted text]

> still not indented.. sorry.. figure that out

Hey Joel, is the Backspace key on your keyboard broken? :-)

This sort of mass (and unnecessary) quoting is why Bottom-Posting gets a 
bad reputation. The reader shouldn't have to scroll through 6+ 
screenfuls of text to see your one, solitary comment. Please snip the 
quoted text to the minimum needed to establish context.

If your mail client doesn't allow deleting the quoted text (and you 
can't get a better mail client!) it is better to Top-Post (heresy!), 
provided your signature shows up above the quoting so we know to stop 
reading.

Thanks in advance,



-- 
Steve
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Request for help with code

2018-11-06 Thread Cameron Simpson
On 06Nov2018 15:50, Joseph Gulizia ", count)

You should see that the expected code is actually reached and run, and 
if it isn't, the corresponding print()s do not happen.

Cheers,
Cameron Simpson 
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Request for help with code

2018-11-06 Thread David Rock
* Mats Wichmann  [2018-11-06 16:54]:
> 
> there must be some solution... guys, do you know of any alternate way to
> send a message to the list if a mail client isn't cooperating? or do we
> have instructions for beating gmail into submission?  Obviously gmail is
> a key part of the modern infrastructure despite its (ahem) misfeatures.

Looking at the mail headers, I'm seeing

Content-Type: text/plain; charset="us-ascii"  

But that is probably just what the final format that gets sent to the list ends
up with.  We might have some suggestions if we know for sure what email client
is being used.  A gmail.com address is not a guarantee that gmail within a
browser is what's being used (I use mutt to send mail through my gmail.com
account all the time).

What's the MUA (mail client)?
If it's in a browser, what browser is being used?

Off the top, I would suggest looking for a "plain text" selection on a dropdown.

-- 
David Rock
da...@graniteweb.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Request for help with code

2018-11-06 Thread Mats Wichmann
On 11/6/18 4:36 PM, Joseph Gulizia wrote:
> Funny using a text editorand showed indented in my browser.   Won't
> bother the list again.

We don't want you to "not bother" us, just hoping to get things in a
state where we can actually help...

here's what we end up seeing:

https://www.mail-archive.com/tutor@python.org/msg79222.html
https://www.mail-archive.com/tutor@python.org/msg79225.html

since unlike most other languages, indentation is a crucial part of the
syntax, we tend to grumble.

there must be some solution... guys, do you know of any alternate way to
send a message to the list if a mail client isn't cooperating? or do we
have instructions for beating gmail into submission?  Obviously gmail is
a key part of the modern infrastructure despite its (ahem) misfeatures.


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Request for help with code

2018-11-06 Thread Cameron Simpson

On 06Nov2018 15:50, Joseph Gulizia 
I'm using the bookazine  "The Python Book" First Edition on pages 13-14 it
gives the code (listed further below).

It asks for user to state a given number of integers (for example 4)...then
user enters integers.  It doesn't stop seeking input after the number
requested thereby creating an infinite loop.


It is vital to preserve the indenting when pasting in code. Indent level 
is critical to Python's control flow. I'm going to look anyway, but 
without the indenting I may misinterpret the logic.


  [...snip...]
  # creates a collection (list) called ints
  ints=list()
  # keeps track of number of intergers
  count=0
  # Keep asking for an interger until we have the required number
  while countHere is where I imagine the problem may lie, but it depends critically 
on the indenting. Your while loop should look something like this:


  while count < target_int:
... read the int ...
if isint == True:
  ints.append(new_int)
  count += 1

However, consider this:

  while count < target_int:
... read the int ...
if isint == True:
  ints.append(new_int)
  count += 1

All I have changed is the indent. This means that the increment of count 
is _outside_ the while loop body. Which means that it never happens 
inside the loop, and therefore count never increases, and therefore the 
end of loop condition is never reached. Infinite loop.


The other likelihood is that isint somehow does not become true. If that 
is the case, the count also never increments.


I suggest that you put several print() statements into the loop at 
strategic points (note the indenting - the same as the block they're 
embedded in):


  while count < target_int:
print("loop: count =", count, "target_int =", target_int)
... read the int ...
if isint == True:
  print("isint is true!")
  ints.append(new_int)
  count += 1
  print("count =>", count)

You should see that the expected code is actually reached and run, and 
if it isn't, the corresponding print()s do not happen.


Cheers,
Cameron Simpson 
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Request for help with code

2018-11-06 Thread Joseph Gulizia
Funny using a text editorand showed indented in my browser.   Won't
bother the list again.

On Tue, Nov 6, 2018, 17:32 Joel Goldstick  On Tue, Nov 6, 2018 at 6:17 PM Joseph Gulizia 
> wrote:
> >
> > Apologies for earlier errors when asking for help -- I am hopeful that
> this
> > shortened post displays properly:
> > The code is Python 2...  trying to solve why loop doesn't stop at given
> > number of integersif I input request for 3 integersit keeps
> asking
> > for integer1...and keeps asking for input,,,so count isn't
> > workingtrying to figure out why.  Pointers please.
> >
> > import sys
> >
> > target_int=raw_input("How many integers?")
> >
> > try:
> > target_int=int(target_int)
> > except ValueError:
> > sys.exit("You must enter an integer")
> >
> > # creates a collection (list) called ints
> >
> > ints=list()
> >
> > # keeps track of number of integers
> >
> > count=0
> >
> > # Keep asking for an integer until we have the required number
> >
> > while count > new_int=raw_input("Please enter integer{0}:".format(count+1))
> > isint=False
> > try:
> > new_int=int(new_int)
> > except:
> > print("You must enter an integer")
> > -
> >
> >
> > On Tue, Nov 6, 2018 at 3:50 PM Joseph Gulizia 
> > wrote:
> >
> > > I'm using the bookazine  "The Python Book" First Edition on pages
> 13-14 it
> > > gives the code (listed further below).
> > >
> > > It asks for user to state a given number of integers (for example
> > > 4)...then user enters integers.  It doesn't stop seeking input after
> the
> > > number requested thereby creating an infinite loop.
> > >
> > > -
> > > CODE
> > > -
> > >
> > > # Python Book Page_13.py
> > > # Joe G.
> > >
> > > # several comment lines explain the code below it.
> > > # Re-typing is good practice
> > >
> > > # We're going to write a program that will ask the user to input an
> > > arbitrary
> > > # number of intergers, store them in a collection, and then demonstrate
> > > how the
> > > # collection would be used in various control structures.
> > >
> > > # Used for the sys.exit function
> > > import sys
> > > # Requests number of intergers
> > > target_int=raw_input("How many intergers?")
> > > # By now, the variable target_int contains a string representtion of
> > > # whatever the user typed.  We need to try and convert that to an
> interger
> > > but
> > > # be ready to # deal with the error if it's not.  Otherwise the program
> > > will
> > > # crash
> > > # Begin the error check
> > > try:
> > > target_int=int(target_int)
> > > except ValueError:
> > > sys.exit("You must enter an interger")
> > > # creates a collection (list) called ints
> > > ints=list()
> > > # keeps track of number of intergers
> > > count=0
> > > # Keep asking for an interger until we have the required number
> > > while count > > new_int=raw_input("Please enter interger{0}:".format(count+1))
> > > isint=False
> > > try:
> > > new_int=int(new_int)
> > > except:
> > > print("You must enter an interger")
> > > # Only carry on if we have an interger.  If not, we'll loop again
> > > # Notice below I use == which is different from =.  The single equals
> sign
> > > is an
> > > # assignment operator whereas the double equals sign is a comparison
> > > operator. I would
> > > # call it a married eguals signbut whenever single is mentioned I
> have
> > > to mention marriage.
> > >
> > > if isint==True:
> > > # Add the interger to the collection
> > > ints.append(new_int)
> > > # Increment the count by 1
> > > count+=1
> > > # print statement ("using a for loop")
> > > print("Using a for loop")
> > > for value in ints:
> > > print(str(value))
> > > # Or with a while loop:
> > > print("Using a while loop")
> > > # We already have the total above, but knowing the len function is very
> > > # useful.
> > > total = len(ints)
> > > count = 0
> > > while count < total:
> > >print(str(ints[count]))
> > >count +=1
> > >
> > > count = 0
> > > while count < total:
> > > print(str(ints[count]))
> > > count += 1
> > >
> > > ---
> > > END OF CODE
> > > ---
> > > Sample output:
> > >
> > > How many integers?3
> > > Please enter integer1:1
> > > Please enter integer1:2
> > > Please enter integer1:3
> > > Please enter integer1:a
> > > You must enter an integer
> > > Please enter integer1:4
> > > Please enter integer1:5
> > > Please enter integer1:6
> > > Please enter integer1:b
> > > You must enter an integer
> > > Please enter integer1:
> > > (Keeps Looping)
> > >
> > > Thanks in advance
> > > Joe
> > >
> > ___
> > Tutor maillist  -  Tutor@python.org
> > To unsubscribe or change subscription options:
> > https://mail.python.org/mailman/listinfo/tutor
>
> still not indented.. sorry.. figure that out
>
> --
> Joel Goldstick
> http://joelgoldstick.com/blog
> http://cc-baseballstats.info/stats/birthdays
>

Re: [Tutor] Request for help with code

2018-11-06 Thread Joel Goldstick
On Tue, Nov 6, 2018 at 6:17 PM Joseph Gulizia  wrote:
>
> Apologies for earlier errors when asking for help -- I am hopeful that this
> shortened post displays properly:
> The code is Python 2...  trying to solve why loop doesn't stop at given
> number of integersif I input request for 3 integersit keeps asking
> for integer1...and keeps asking for input,,,so count isn't
> workingtrying to figure out why.  Pointers please.
>
> import sys
>
> target_int=raw_input("How many integers?")
>
> try:
> target_int=int(target_int)
> except ValueError:
> sys.exit("You must enter an integer")
>
> # creates a collection (list) called ints
>
> ints=list()
>
> # keeps track of number of integers
>
> count=0
>
> # Keep asking for an integer until we have the required number
>
> while count new_int=raw_input("Please enter integer{0}:".format(count+1))
> isint=False
> try:
> new_int=int(new_int)
> except:
> print("You must enter an integer")
> -
>
>
> On Tue, Nov 6, 2018 at 3:50 PM Joseph Gulizia 
> wrote:
>
> > I'm using the bookazine  "The Python Book" First Edition on pages 13-14 it
> > gives the code (listed further below).
> >
> > It asks for user to state a given number of integers (for example
> > 4)...then user enters integers.  It doesn't stop seeking input after the
> > number requested thereby creating an infinite loop.
> >
> > -
> > CODE
> > -
> >
> > # Python Book Page_13.py
> > # Joe G.
> >
> > # several comment lines explain the code below it.
> > # Re-typing is good practice
> >
> > # We're going to write a program that will ask the user to input an
> > arbitrary
> > # number of intergers, store them in a collection, and then demonstrate
> > how the
> > # collection would be used in various control structures.
> >
> > # Used for the sys.exit function
> > import sys
> > # Requests number of intergers
> > target_int=raw_input("How many intergers?")
> > # By now, the variable target_int contains a string representtion of
> > # whatever the user typed.  We need to try and convert that to an interger
> > but
> > # be ready to # deal with the error if it's not.  Otherwise the program
> > will
> > # crash
> > # Begin the error check
> > try:
> > target_int=int(target_int)
> > except ValueError:
> > sys.exit("You must enter an interger")
> > # creates a collection (list) called ints
> > ints=list()
> > # keeps track of number of intergers
> > count=0
> > # Keep asking for an interger until we have the required number
> > while count > new_int=raw_input("Please enter interger{0}:".format(count+1))
> > isint=False
> > try:
> > new_int=int(new_int)
> > except:
> > print("You must enter an interger")
> > # Only carry on if we have an interger.  If not, we'll loop again
> > # Notice below I use == which is different from =.  The single equals sign
> > is an
> > # assignment operator whereas the double equals sign is a comparison
> > operator. I would
> > # call it a married eguals signbut whenever single is mentioned I have
> > to mention marriage.
> >
> > if isint==True:
> > # Add the interger to the collection
> > ints.append(new_int)
> > # Increment the count by 1
> > count+=1
> > # print statement ("using a for loop")
> > print("Using a for loop")
> > for value in ints:
> > print(str(value))
> > # Or with a while loop:
> > print("Using a while loop")
> > # We already have the total above, but knowing the len function is very
> > # useful.
> > total = len(ints)
> > count = 0
> > while count < total:
> >print(str(ints[count]))
> >count +=1
> >
> > count = 0
> > while count < total:
> > print(str(ints[count]))
> > count += 1
> >
> > ---
> > END OF CODE
> > ---
> > Sample output:
> >
> > How many integers?3
> > Please enter integer1:1
> > Please enter integer1:2
> > Please enter integer1:3
> > Please enter integer1:a
> > You must enter an integer
> > Please enter integer1:4
> > Please enter integer1:5
> > Please enter integer1:6
> > Please enter integer1:b
> > You must enter an integer
> > Please enter integer1:
> > (Keeps Looping)
> >
> > Thanks in advance
> > Joe
> >
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor

still not indented.. sorry.. figure that out

-- 
Joel Goldstick
http://joelgoldstick.com/blog
http://cc-baseballstats.info/stats/birthdays
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Request for help with code

2018-11-06 Thread Joseph Gulizia
Apologies for earlier errors when asking for help -- I am hopeful that this
shortened post displays properly:
The code is Python 2...  trying to solve why loop doesn't stop at given
number of integersif I input request for 3 integersit keeps asking
for integer1...and keeps asking for input,,,so count isn't
workingtrying to figure out why.  Pointers please.

import sys

target_int=raw_input("How many integers?")

try:
target_int=int(target_int)
except ValueError:
sys.exit("You must enter an integer")

# creates a collection (list) called ints

ints=list()

# keeps track of number of integers

count=0

# Keep asking for an integer until we have the required number

while count
wrote:

> I'm using the bookazine  "The Python Book" First Edition on pages 13-14 it
> gives the code (listed further below).
>
> It asks for user to state a given number of integers (for example
> 4)...then user enters integers.  It doesn't stop seeking input after the
> number requested thereby creating an infinite loop.
>
> -
> CODE
> -
>
> # Python Book Page_13.py
> # Joe G.
>
> # several comment lines explain the code below it.
> # Re-typing is good practice
>
> # We're going to write a program that will ask the user to input an
> arbitrary
> # number of intergers, store them in a collection, and then demonstrate
> how the
> # collection would be used in various control structures.
>
> # Used for the sys.exit function
> import sys
> # Requests number of intergers
> target_int=raw_input("How many intergers?")
> # By now, the variable target_int contains a string representtion of
> # whatever the user typed.  We need to try and convert that to an interger
> but
> # be ready to # deal with the error if it's not.  Otherwise the program
> will
> # crash
> # Begin the error check
> try:
> target_int=int(target_int)
> except ValueError:
> sys.exit("You must enter an interger")
> # creates a collection (list) called ints
> ints=list()
> # keeps track of number of intergers
> count=0
> # Keep asking for an interger until we have the required number
> while count new_int=raw_input("Please enter interger{0}:".format(count+1))
> isint=False
> try:
> new_int=int(new_int)
> except:
> print("You must enter an interger")
> # Only carry on if we have an interger.  If not, we'll loop again
> # Notice below I use == which is different from =.  The single equals sign
> is an
> # assignment operator whereas the double equals sign is a comparison
> operator. I would
> # call it a married eguals signbut whenever single is mentioned I have
> to mention marriage.
>
> if isint==True:
> # Add the interger to the collection
> ints.append(new_int)
> # Increment the count by 1
> count+=1
> # print statement ("using a for loop")
> print("Using a for loop")
> for value in ints:
> print(str(value))
> # Or with a while loop:
> print("Using a while loop")
> # We already have the total above, but knowing the len function is very
> # useful.
> total = len(ints)
> count = 0
> while count < total:
>print(str(ints[count]))
>count +=1
>
> count = 0
> while count < total:
> print(str(ints[count]))
> count += 1
>
> ---
> END OF CODE
> ---
> Sample output:
>
> How many integers?3
> Please enter integer1:1
> Please enter integer1:2
> Please enter integer1:3
> Please enter integer1:a
> You must enter an integer
> Please enter integer1:4
> Please enter integer1:5
> Please enter integer1:6
> Please enter integer1:b
> You must enter an integer
> Please enter integer1:
> (Keeps Looping)
>
> Thanks in advance
> Joe
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Request for help with code

2018-11-06 Thread Steven D'Aprano
On Tue, Nov 06, 2018 at 03:50:42PM -0600, Joseph Gulizia wrote:
> I'm using the bookazine  "The Python Book" First Edition on pages 13-14 it
> gives the code (listed further below).
> 
> It asks for user to state a given number of integers (for example 4)...then
> user enters integers.  It doesn't stop seeking input after the number
> requested thereby creating an infinite loop.

The first and most important rule for asking for help with code is to 
always post plain, unformatted text, not "Rich Text" (formatted text, 
styled text). Don't add colours, highlighting, bold, italic, fancy 
fonts, dancing paperclips or anything else, because when you do, it 
destroys the necessary indentation of the code and makes it impossible 
to run or debug. For example, your code shows up like this:


# Begin the error check
try:
target_int=int(target_int)
except ValueError:
sys.exit("You must enter an interger")


In that case, we could(?) guess the correct indentation, but (1) 
sometimes we can't, and (2) we shouldn't have to.

The *second* most important rule for posting code is to *keep it 
simple*. We're volunteers, not slaves, and you should always ask first 
before posting masses of code for us to investigate. Anything more than, 
oh, say, thirty lines (including comments) counts as masses.

Please try reading this:

http://sscce.org/

it is written for Java programmers but the advice applies as well here. 
Before posting your entire code, take the time to simplify it to a 
*mimimal example* which demonstrates the same problem. Half the time 
this will allow you to solve the problem yourself, and the other half of 
the time, it makes it easier on us slaves! I mean volunteers.

At a *guess*, and this is purely a guess because the lack of indentation 
makes it impossible to understand the structure of your code, I think 
the infinite loop is probably intentional. If you guess wrongly, it asks 
you to guess again, *forever*, until you guess correctly.

But as I said, I can't really tell.



-- 
Steve
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Request for help with code

2018-11-06 Thread Bob Gailer
On Nov 6, 2018 4:51 PM, "Joseph Gulizia"  wrote:
>
> I'm using the bookazine  "The Python Book" First Edition on pages 13-14 it
> gives the code (listed further below).
>
> It asks for user to state a given number of integers (for example
4)...then
> user enters integers.  It doesn't stop seeking input after the number
> requested thereby creating an infinite loop.
>
> -
> CODE
> -
>
> # Python Book Page_13.py
> # Joe G.
>
> # several comment lines explain the code below it.
> # Re-typing is good practice
>
> # We're going to write a program that will ask the user to input an
> arbitrary
> # number of intergers, store them in a collection, and then demonstrate
how
> the
> # collection would be used in various control structures.
>
> # Used for the sys.exit function
> import sys
> # Requests number of intergers
> target_int=raw_input("How many intergers?")
> # By now, the variable target_int contains a string representtion of
> # whatever the user typed.  We need to try and convert that to an interger
> but
> # be ready to # deal with the error if it's not.  Otherwise the program
will
> # crash
> # Begin the error check
> try:
> target_int=int(target_int)
> except ValueError:
> sys.exit("You must enter an interger")
> # creates a collection (list) called ints
> ints=list()
> # keeps track of number of intergers
> count=0
> # Keep asking for an interger until we have the required number
> while count new_int=raw_input("Please enter interger{0}:".format(count+1))
> isint=False
> try:
> new_int=int(new_int)
> except:
> print("You must enter an interger")
> # Only carry on if we have an interger.  If not, we'll loop again
> # Notice below I use == which is different from =.  The single equals sign
> is an
> # assignment operator whereas the double equals sign is a comparison
> operator. I would
> # call it a married eguals signbut whenever single is mentioned I have
> to mention marriage.
>
> if isint==True:
> # Add the interger to the collection
> ints.append(new_int)
> # Increment the count by 1
> count+=1
> # print statement ("using a for loop")
> print("Using a for loop")
> for value in ints:
> print(str(value))
> # Or with a while loop:
> print("Using a while loop")
> # We already have the total above, but knowing the len function is very
> # useful.
> total = len(ints)
> count = 0
> while count < total:
>print(str(ints[count]))
>count +=1
>
> count = 0
> while count < total:
> print(str(ints[count]))
> count += 1
>
> ---
> END OF CODE
> ---
> Sample output:
>
> How many integers?3
> Please enter integer1:1
> Please enter integer1:2
> Please enter integer1:3
> Please enter integer1:a
> You must enter an integer
> Please enter integer1:4
> Please enter integer1:5
> Please enter integer1:6
> Please enter integer1:b
> You must enter an integer
> Please enter integer1:
> (Keeps Looping)
>
> Thanks in advance

Your code came through with all of the indentation removed. Please be sure
to send plain text. We could guess at the indentation but we might get it
wrong.

With the indentation corrected the code you supplied does not agree with
the execution. Note the difference between integer and interger.

You also did not make any request. Please in the future tell us what you
want from us.

The fact that the program keeps asking for integer 1 suggest that count is
not being incremented. This would also explain why the loop never ends.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Request for help with code

2018-11-06 Thread Joseph Gulizia
I'm using the bookazine  "The Python Book" First Edition on pages 13-14 it
gives the code (listed further below).

It asks for user to state a given number of integers (for example 4)...then
user enters integers.  It doesn't stop seeking input after the number
requested thereby creating an infinite loop.

-
CODE
-

# Python Book Page_13.py
# Joe G.

# several comment lines explain the code below it.
# Re-typing is good practice

# We're going to write a program that will ask the user to input an
arbitrary
# number of intergers, store them in a collection, and then demonstrate how
the
# collection would be used in various control structures.

# Used for the sys.exit function
import sys
# Requests number of intergers
target_int=raw_input("How many intergers?")
# By now, the variable target_int contains a string representtion of
# whatever the user typed.  We need to try and convert that to an interger
but
# be ready to # deal with the error if it's not.  Otherwise the program will
# crash
# Begin the error check
try:
target_int=int(target_int)
except ValueError:
sys.exit("You must enter an interger")
# creates a collection (list) called ints
ints=list()
# keeps track of number of intergers
count=0
# Keep asking for an interger until we have the required number
while counthttps://mail.python.org/mailman/listinfo/tutor