Question again
Michael F. Stemper
michael.stemper at gmail.com
Fri Sep 17 17:38:38 EDT 2021
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
More information about the Python-list
mailing list