A new guy needs help!

Hello all,

I was messing around and trying different things out with the lessons that were given and I have run into an issue. I don’t know what I did wrong and was hoping someone could nudge me in the right direction. Thank you

The if/else temperature lesson, I changed it to this

temperature = input("What is the Temp? ")
if int(temperature) > 75:
print(“It’s warm out side”)
print(“Drink water”)
if int(temperature) < 30:
print(“It is cold take a jacket”)
elif int(temperature):
print(“It’s nice out side”)
print(“Have a Great Day”)

Which worked just fine.

So then I try to simplify it

temperature = input("What is the Temp? ")

msg = “it’s hot” if int(temperature) > 75: “it’s cold” if int(temperature) < 30: “it’s nice” elif int(temperature):


and I keep getting a problem
“resource”: “/d:/Users/jamie/Documents/hello world/app3.py”,
“owner”: “python”,
“code”: “syntax-error”,
“severity”: 8,
“message”: “invalid syntax (, line 2)”,
“source”: “pylint”,
“startLineNumber”: 2,
“startColumn”: 43,
“endLineNumber”: 2,
“endColumn”: 43

What did I do wrong? I am uber new at this so please forgive my ignorance.

temperature = int(input("What is the Temp? "))
if temperature > 75:
    print('It’s warm out side')
    print('Drink water')
if temperature < 30:
    print('It is cold take a jacket')
    print('It’s nice out side')
    print('Have a Great Day')

Try this code, worked for me :grinning:

How did you paste the code without it messing up?

@James See this post.

I pasted the code between ~~~ and ~~~

I will take a look at the link now. Thank you

I know this is kind of an old post, but I’m new to Python and I wanted to figure this out myself. If you want to get it into one line, I think that this is the way to do it, although I’m pretty sure that this goes against PEP 8:

temperature = input("What is the Temp? ")
msg = “it’s hot” if int(temperature) > 75 else “it’s cold” if int(temperature) < 30 else “it’s nice”