Click here to Skip to main content
15,884,064 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
a = "Hello, world!"
print(a[-5:-2])
question = input("Do you want to convert " + a +" in upper case? " )

if question == str( 'Yes' or 'yes'):
    print(a.upper())
else:
    question2 = input("Do you want to " + a + "into lower case? ")
    if question2 == str( 'Yes' or 'yes'):
        print(a.lower())


What I have tried:

i have tried changing it several times i dont know what should i do any idea whats the issue?
Posted
Updated 13-Jun-21 10:06am

Try this:
Python
a = "Hello, world!"
print(a[-5:-2])
question = input("Do you want to convert " + a +" in upper case? " )

if question == 'yes':
    print(a.upper())
else:
    question2 = input("Do you want to " + a + "into lower case? ")
    if question2 == 'yes':
        print(a.lower())
 
Share this answer
 
Comments
CPallini 14-Jun-21 2:17am    
5.
Lakshay Sahu 15-Jun-21 15:09pm    
what was the issue
OriginalGriff 15-Jun-21 15:53pm    
Compare your code - which doesn't work - with mine - which does.
It should be pretty obvious what you did wrong! :laugh:
i dont know what should i do any idea whats the issue?

The issue is that you didn't read the documentation.
It happen the programming languages are no plain english, you need to learn how to express what you want to do.
This is not Python:
Python
if question == str( 'Yes' or 'yes'):
    print(a.upper())

You have to transform to:
Python
if question == 'Yes' or question == 'yes':
    print(a.upper())
 
Share this answer
 
Comments
CPallini 14-Jun-21 2:18am    
'Documentation'? 'Documentation', no less!
5.
Patrice T 14-Jun-21 2:22am    
Thank you
Lakshay Sahu 15-Jun-21 15:10pm    
haha actually i am just a newbie
Patrice T 15-Jun-21 16:22pm    
I guessed you are a newbie, because this mistake is done only by newbies. :)
How to build a complex condition is something you learn by reading documentation, or by following good tutorial, but you don't guess.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900