Question again

Avi Gross avigross at verizon.net
Thu Sep 16 20:25:44 EDT 2021


Alan,

I wonder if this is yet another case when a pop-up window closes rapidly
when done and any last text written is just not perceived.

Good design in such cases makes a final pause till the user acknowledges in
some way that they are done and then no more messages!

Avi

-----Original Message-----
From: Python-list <python-list-bounces+avigross=verizon.net at python.org> On
Behalf Of Alan Gauld via Python-list
Sent: Thursday, September 16, 2021 8:11 PM
To: python-list at python.org
Subject: Re: Question again

On 16/09/2021 06:50, af kh wrote:
> Hello,
> I was doing some coding on a website called replit

I have no idea what that is but...

> after answering 'no' or 'yes' after the last sentence I wrote, the 
> Python window shut off,

That's what you told it to do in the code.
Regardless of which answer the user gives the program reaches the end and
stops.

>  in replit I added one more sentence, but it isn't shown on Python,

I dn;t know what this means.

> #Gives greetings to the user
> import random
...
> #Ask to pick between numbers 1~10 to see if you will get lucky today: 
> Third question number = input("Please pick between numbers 1~10 to see 
> your luck for today: ")
> 
> #From number 1~3 and an answer
> if number == "1" or number == "2" or number == "3" :
>   print("You're in greeeeat luck today!")
> 
> #From number 4~7 and an answer
> elif number == "4" or number == "5" or number == "6" :
>   print("damn, bad luck is coming your way")

The cde and comment are not consistent.

> #From number 8~10 and an answer
> elif number == "7" or number == "8" or number == "9" or number == "10" :
>   print("I cannot sense any luck today, try again next time")

Same here.

> #Add a statement and question: Fourth question print("That will be all 
> for today's chitchat, woohooo! would you like to exit the chat?") 
> #User says 'yes'
> reply = input()
> 
> #If user says 'yes' reply 'wait hold on! are you really leaving??': 
> Fifth question if reply == "yes" :
>   print("Wait hold on! are you really leaving??")
> 
> #User answers
> answer = input()
> #If user says 'yes' again, reply 'fine! bye then!'
> if answer == "yes" :
>   print("Fine! bye then!")


Shouldn't those lines be indented as part of the if statement above?

> #Other than that if user says 'no', reply 'just kidding we're done here
haha'
> elif answer == "no" :
>   print("just kidding we're done here haha")

But the code always gets to the end, there is nothing to stop it exiting.


--
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


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



More information about the Python-list mailing list