0

Can someone please explain this code?

The course that i'm taking didn't explain it at all https://code.sololearn.com/WpcrgMGFcCsh/?ref=app

25th Jun 2022, 11:59 PM
Varin
Varin - avatar
4 Answers
+ 3
Its ternary operater. Read it like a sentence. But anyways, think about it like this: Everything up until the question mark is the question. The indentation is weird, but it should read: isRaining ? .... It takes that statement or whatever and gets a boolean True False value from it. Then you got two choices here. If the statement is true, it does the first code before the colon. If false, it does the code after. The colon ':' is to seperate the choices. So then it reads: Is it raining? If yes, you need a jacket. If no, you have no need for a jacket. But it would only print one of those.
26th Jun 2022, 12:10 AM
Slick
Slick - avatar
+ 1
It's raining. Is it raining? You need a coat. It's not raining. Is it raining? No need for a coat.
26th Jun 2022, 12:02 AM
Slick
Slick - avatar
0
Slick yep i mean this ? : thing i don't understand what it dose and the variable name after the variable
26th Jun 2022, 12:03 AM
Varin
Varin - avatar
0
Slick thanks
26th Jun 2022, 12:13 AM
Varin
Varin - avatar