Re: [Tutor] Coding

2014-12-09 Thread Awais Idris
The problem is when i enter my first choice it accepts it fine and well.
When it says would you like a second item, andi say yes it listd the
options and says have a good day and the program cuts off. In wondering if
this is a problem with the statements?

On 8 December 2014 at 22:49, Awais Idris <2010-3...@slougheton.com> wrote:

> Ok thank you i appreciate your help
>
> On Monday, 8 December 2014, Danny Yoo  wrote:
>
>> On Mon, Dec 8, 2014 at 12:14 PM, Awais Idris <2010-3...@slougheton.com>
>> wrote:
>> > The problem is when i enter my first choice it accepts it fine and well.
>> > When it says would you like a second item, andi say yes it listd the
>> options
>> > and says have a good day and the program cuts off. In wondering if this
>> is a
>> > problem with the loops?
>> >
>>
>> Please use Reply to All on this mailing list, so that all of us here
>> can help respond.  I have a day job, so sometimes I actually have to
>> do something other than answer email.  :P
>>
>> From your description, it sounds like you should look at the
>> *conditions* in your if statements, because they aren't branching in a
>> way that you want.  Other replies to your thread should point out
>> things you want to look at.  Read all the replies, and start asking
>> questions when you hit something you don't understand.  This is a
>> conversation: we'll listen to what you're saying.
>>
>>
>> Also, be careful about what terms you are using.  You are using the
>> term "loop", and have done so repeatedly, but there are no loops in
>> your program, as Alan has pointed out earlier.
>>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Coding

2014-12-09 Thread Alan Gauld

On 08/12/14 23:06, Awais Idris wrote:

The problem is when i enter my first choice it accepts it fine and well.
When it says would you like a second item, andi say yes it listd the
options and says have a good day and the program cuts off. In wondering if
this is a problem with the statements?


As Danny pointed out both Steven and I suggested a better way to test. 
In case you missed it here is Steven's response:



Actually it sees it as:

if ((FirstChoice == 'Coke') or 'Pepsi' or 'Water'):

which will always evaluate as True.

*Technically* it will evaluate as either True or 'Pepsi', which is a
truthy value, so the if block will always run.

What we actually want is one of these:

# The long way
if (FirstChoice == 'Coke') or (FirstChoice == 'Pepsi') or (FirstChoice 
== 'Water'):



# The short way
if FirstChoice in ('Coke', 'Pepsi', 'Water'):

###

And since you already have the drinks in a set you can
shorten the last line even further to:

if FirstChoice in drinks:



--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


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


Re: [Tutor] Memory management in Python

2014-12-09 Thread Adam Jensen
On Wed, 26 Nov 2014 14:08:53 +
Raúl Cumplido  wrote:

> This web is quite useful to visualize what is happening:
> http://www.pythontutor.com/visualize.html#mode=edit
> 

Very nifty web app, thanks for the link!
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Memory management in Python

2014-12-09 Thread Leo Ufimtsev

Thanks for sharing.

On 12/09/2014 10:31 AM, Adam Jensen wrote:

On Wed, 26 Nov 2014 14:08:53 +
Raúl Cumplido  wrote:


This web is quite useful to visualize what is happening:
http://www.pythontutor.com/visualize.html#mode=edit



Very nifty web app, thanks for the link!
___
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] Coding

2014-12-09 Thread Awais Idris
I haven't got a reply from alan and stephen

On 8 December 2014 at 23:34, Danny Yoo  wrote:

> On Mon, Dec 8, 2014 at 3:06 PM, Awais Idris <2010-3...@slougheton.com>
> wrote:
> > The problem is when i enter my first choice it accepts it fine and well.
> > When it says would you like a second item, andi say yes it listd the
> options
> > and says have a good day and the program cuts off. In wondering if this
> is a
> > problem with the statements?
>
> Hi Awais,
>
> Yes, there is a problem that we can see.  Look for Alan and Stephen's
> responses in your email inbox.  They should explain what's going on,
> and how to correct the bug.  Can you confirm that you're getting these
> emails from them?
>
>
> You can also see these responses if you look at the email archive.
>
>
> Your question:
>
>  https://mail.python.org/pipermail/tutor/2014-December/103581.html
>
> and the responses:
>
> https://mail.python.org/pipermail/tutor/2014-December/103584.html
> https://mail.python.org/pipermail/tutor/2014-December/103586.html
> https://mail.python.org/pipermail/tutor/2014-December/103588.html
> https://mail.python.org/pipermail/tutor/2014-December/103590.html
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Coding

2014-12-09 Thread Alan Gauld

On 09/12/14 17:50, Awais Idris wrote:

I haven't got a reply from alan and stephen


You should have gotten another one from me, quoting Steven's
response, earlier today.

How are you reading the list? Is it by email or are you using an archive 
or newsfeed. (For example I use the gmane.org newsfeed)


And are you checking the email account that you subscribed with?
I notice that this address: 2010-3...@slougheton.com
is not registered on the tutor mailing list, so won't be
getting sent any responses.


Yes, there is a problem that we can see.  Look for Alan and Stephen's
responses in your email inbox.  They should explain what's going on,
and how to correct the bug.  Can you confirm that you're getting these
emails from them?


PS. I'm using ReplyAll rather than ReplyLiust to ensure Awais gets
the mail, apologies for any duplicates received by other recipients.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


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