0
How to properly use the if statement into practice?
I'm confused đ€ with the if statements when it comes to the string and numeric variables how to use it, correctly because you can't use the same method when it comes to different variables types please any nerd đ€ help! đ
4 Answers
+ 3
LIMO ,
you have started just 5 days ago ith learning in sololearn. so please be patient. to learn coding will take some time.
+ 3
LIMO ,
here are links to some short tutorials from the community sections:
(it is also recommended to do exercises with all of them)
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2277/?ref=app
https://www.sololearn.com/learn/Python/2278/?ref=app
https://www.sololearn.com/learn/Python/2500/?ref=app
+ 1
I feel like my head is swollen when I can't figure out a problem.
0
if statements work technically the same for all data types. The difference is with what you are testing.
I don't know what is your problem here, so I will try with overall explanation.
Example 1.
if my_string == "Hello":
# string is "Hello"
else:
# it's not "Hello" string
Example 2.
if some_var is None:
# variable is None
else:
# variable is not None
Example 3.
if some_int == "Hello":
# will never be true, if we know that variable is holdong integer type, while we are checking for specific string