1
PersonsName = input('Enter your name: ')
print('Hello', PersonsName)

AnswerToHowAreYouToday = input('How are you feeling today? Are you doing Good or Bad?')


print('Ok', PersonsName,'So today you are basically feeling', AnswerToHowAreYouToday, '.')


a = "Good"
b = "Bad"
if AnswerToHowAreYouToday: a
print('Good')
else:
    print('Bad')
4
  • 4
    1- It's not indented properly 2- AnswerToHowAreYouToday is string, not boolean or 3- you don't compare equality with :, you do it with ==. The : comes at the end of the if statement. Commented Dec 24, 2019 at 7:42
  • 1
    Don't just paste your code here and ask for help. Please first describe what problems you have encountered and what have you tried yourself to solve the problem. Commented Dec 24, 2019 at 7:43
  • 1
    If you want print how he is feeling just print AnswerToHowAreYouToday. There is no need of if else here. If AnswerToHowAreYouToday is something other than "good" and "bad" you would get no output. Commented Dec 24, 2019 at 8:03
  • Everybody, thank you for your help. I am sure I will have more questions for you. I will apply my learnings and report back. Commented Dec 28, 2019 at 22:54

2 Answers 2

3

Your if else statement indentation is wrong. Generally four whitespaces are used for indentation and is preferred over tabs. Indentation can be ignored in line continuation. But it's a good idea to always indent.

PersonsName = input('Enter your name: ')
print('Hello', PersonsName)

AnswerToHowAreYouToday = input('How are you feeling today? Are you doing Good or Bad?')


print('Ok', PersonsName,'So today you are basically feeling', AnswerToHowAreYouToday, '.')


a = "Good"
b = "Bad"
if AnswerToHowAreYouToday == a:
    print('Good')
else:
    print('Bad')
Sign up to request clarification or add additional context in comments.

Comments

2

Your if AnswerToHowAreYouToday: a should be like this if AnswerToHowAreYouToday == a. @Santhos have mentioned it but when your code running your output display like this

Enter your name: Deepak                                                                                                              
Hello Deepak                                                                                                                         
How are you feeling today? Are you doing Good or Bad?Good                                                                            
Ok Deepak So today you are basically feeling Good .                                                                                  
Good 

You can see two Good printed at last. To avoid these issues you can improved your code like this

PersonsName = input('Enter your name: ')
print('Hello', PersonsName)

AnswerToHowAreYouToday = input('How are you feeling today? Are you doing Good or Bad? ')

print('Ok', PersonsName,'So today you are basically feeling ', end = '')

a = "Good"
b = "Bad"
if AnswerToHowAreYouToday == a:
    print('Good.')
else:
    print('Bad.')

Then Output will be:

Enter your name: Deepak                                                                                                              
Hello Deepak                                                                                                                         
How are you feeling today? Are you doing Good or Bad? Good                                                                            
Ok Deepak So today you are basically feeling Good. 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.