Mailing List Archive

Question again
Hello,
I was doing some coding on a website called replit then I extracted the file, and opened it in Python. For some reason, after answering 'no' or 'yes' after the last sentence I wrote, the Python window shut off, in replit I added one more sentence, but it isn't shown on Python, it just shuts off. Why is that? please reply to me soon since I need to submit it as an assignment for my class.

Code on replit:
#Title: Week 2: Chatbot with personality
#Author: Afnan Khan
#Date:9/15/21
#Description: Ask at least 3 questions to the user
#and create a creative topic

#Gives greetings to the user
import random

greetings = ["Hello, I'm Mr. ChatBot!", "Hi, I'm Mr. ChatBot!", "Hey~, I'm Mr. ChatBot!"]
comment = random.choice(greetings)
print(comment)
#Learn about the user's Name: First question
name = input("What is your name? ")

#Greet the User
print("Nice to meet you, " + name)

#Ask the user about their day: Second question
print("How is your day going? ")

#The user replies
reply = input()

#If user says 'amazing', reply with 'I am glad!'
if reply == "amazing" :
print("I am glad!")

#If user says 'Alright', reply with 'that's good'
elif reply == "alright" :
print("that's good")

#If user says 'bad', reply with 'Do not worry things will get better'
elif reply == "bad" :
print("Do not worry things will get better")

#Else than that type 'I see'
else :
print("I see!")

#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")

#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")

#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!")

#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")


Regards,
Aya
--
https://mail.python.org/mailman/listinfo/python-list
Re: Question again [ In reply to ]
On 9/16/2021 1:50 AM, af kh wrote:
> Hello,
> I was doing some coding on a website called replit then I extracted the file, and opened it in Python. For some reason, after answering 'no' or 'yes' after the last sentence I wrote, the Python window shut off, in replit I added one more sentence, but it isn't shown on Python, it just shuts off. Why is that? please reply to me soon since I need to submit it as an assignment for my class.
>
> Code on replit:
> #Title: Week 2: Chatbot with personality
> #Author: Afnan Khan
> #Date:9/15/21
> #Description: Ask at least 3 questions to the user
> #and create a creative topic
>
> #Gives greetings to the user
> import random
>
> greetings = ["Hello, I'm Mr. ChatBot!", "Hi, I'm Mr. ChatBot!", "Hey~, I'm Mr. ChatBot!"]
> comment = random.choice(greetings)
> print(comment)
> #Learn about the user's Name: First question
> name = input("What is your name? ")
>
> #Greet the User
> print("Nice to meet you, " + name)
>
> #Ask the user about their day: Second question
> print("How is your day going? ")
>
> #The user replies
> reply = input()
>
> #If user says 'amazing', reply with 'I am glad!'
> if reply == "amazing" :
> print("I am glad!")
>
> #If user says 'Alright', reply with 'that's good'
> elif reply == "alright" :
> print("that's good")
>
> #If user says 'bad', reply with 'Do not worry things will get better'
> elif reply == "bad" :
> print("Do not worry things will get better")
>
> #Else than that type 'I see'
> else :
> print("I see!")
>
> #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")
>
> #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")
>
> #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!")
>
> #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")
>
>
> Regards,
> Aya


I don't understand your issue, but this code runs fine for me.

--
https://mail.python.org/mailman/listinfo/python-list
Re: Question again [ In reply to ]
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
RE: Question again [ In reply to ]
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@python.org> On
Behalf Of Alan Gauld via Python-list
Sent: Thursday, September 16, 2021 8:11 PM
To: python-list@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

--
https://mail.python.org/mailman/listinfo/python-list
Re: Question again [ In reply to ]
On 17/09/2021 12.25, Avi Gross via Python-list wrote:
> 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!
> -----Original Message-----
> From: Python-list <python-list-bounces+avigross=verizon.net@python.org> On
> Behalf Of Alan Gauld via Python-list
> Sent: Thursday, September 16, 2021 8:11 PM
> To: python-list@python.org
> Subject: Re: Question again
>
> On 16/09/2021 06:50, af kh wrote:
>> after answering 'no' or 'yes' after the last sentence I wrote, the

Are you using MS-Windows?
Are you executing the program directly/from the menu?
(or do you first start a terminal window, and then run Python within that)

--
Regards,
=dn
--
https://mail.python.org/mailman/listinfo/python-list
Re: Question again [ In reply to ]
On 16/09/2021 19.11, Alan Gauld wrote:
> 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.

This is, of course, why comments shouldn't just translate the code
into English. They'll get out of synch. Instead, comments should say
*why* the code is doing what it does.

--
Michael F. Stemper
Exodus 22:21
--
https://mail.python.org/mailman/listinfo/python-list