The If-Else statement is designed to build on the if statement’s logic. Here, we ask if something is the case, and, if it is we do something. Then we say otherwise, which is contingent on the previous if statement, do something else. If the previous if statement is true, then the else will not run. If the if statement is false, then the else statement will run.
Sample code for this basics series: http://pythonprogramming.net/beginner-python-programming-tutorials/
Python 3 Programming tutorial Playlist: http://www.youtube.com/watch?v=oVp1vrfL_w4&feature=share&list=PLQVvvaa0QuDe8XSftW-RAxdo6OmaeL85M
In this python programming tutorial video you are shown how to use the if-else statements together.
http://seaofbtc.com
http://sentdex.com
http://hkinsley.com
https://twitter.com/sentdex
Bitcoin donations: 1GV7srgR4NJx4vrk7avCmmVQQrqmv87ty6
Amazon Auto Links: No products found.
Hi , I am getting error while executing if else block in python 3.6.4 IDE shell but same thing when I am executing in Terminal , it’s working as expected . Could you please let me know the point of error.
IDE Code / Error :
>>> if x > y :
print (‘x’)
else :
SyntaxError: invalid syntax
Terminal :
>>> if x>y:
… print(‘x’)
… else :
… print(‘y’)
y
python 3.6.ob4 is telling me the else statement and the elif statements are invalid syntax
I like the large font you use it’s easy to see the code, Thanks.
a=int(input(“How old are you?”))
if a >= 16 < 18: b=input("Are you at sixth form, work or at college?") print("You work at",b,".") if a > 18:
c=input(“Have you started taking driving lessons yet?”)
Why does this not work!!
Thankyou, just starting to learn python. subscribed.
I had a constant error with using else but thanks to your help i managed to create my first if else code and im really happy 😀
Thank you!
This one is confusing, because if if is true, else is not and if else is true, if is not true.
Confusing, but true, else, not true.
Here’s my code but it doesn’t go to the else statement if the if statement is false. Everything else works besides if statement.
1 #!/bin/python
2 var = raw_input (“hey, what’s your name? “)
3 print “hello,”, var, “nice to meet you. What do you like to do?”
4 var = raw_input()
5 print var, “? I like to do that as well!”
6 print “what do you like to eat? “,
7 var = raw_input()
8 print “I like to eat” ,var, “as well! But, I also like your mother’s pussy. What is the temperature right now?”
9 if raw_input() > 30:
10 print (“As usual”)
11 else:
12 print (“That’s not possible”)
~
Any ideas y it won’t go to else statement?
Thanks in advance BTW.
Best basic python series… even better than some of the paid courses!
great work
1:21 TTTRRRRIIIGGGEEERRRREEEDDD
Does python have data vectors like c++?
please, someone help me… This code is not working
age = input()
if age > int(13) :
print(“You can take this test :)”)
else:
print (“You can’t take this test.”)
print (” But I am really nice so I’m going to let you take it “)
print (“Are you ready?”)
I know it sounds stupid but I want to make a software where u type a gun name in fortnite but I only can do one gun.i need help
You’re great at explaining this stuff man, thank you for posting these vids- very helpful
I wonder to know if there is a function that can solve such problem, imagine we have :
a = 56123145678561615615615616515665156123145678561615615615616515665156123
b = 56123145678561615615615616515665156123145678561615615615616515665157123
numbers in A and B, seem to be equal but there is only one number which is not the same in B , is’t possible to know what is the unmatched number in B using python ?
Actually, I know the if else and elif functions for Python. I’ve been working on a project that can detect if Radiostations are on the air or not. But I need someone to give me the source code of a program that can detect sound. Can you help?
I have to go to your videos because my computer programming teacher isn’t great at explaining and I would like a nice grade. Thanks!
sir its so complicated and not understand
Thankyou for this video it really helped me do my homework 🙂
I wrote some code with multiple input statements at once for a simple RPG inventory tutorial. are you able to do that because it runs the if statement even lg the condition is not true. Ex.
looting = input(“Do you wish to continue?nyes or no.”)
if looting == “yes” or “Yes”:
print(“Your character has just defeated a ‘Basic Rouge'”)
with some other input staments in here.
then at the bottom is
else:
print(“I’m sorry you must have typed that wrong. You must restart the tutorial.”)
But even if i put 10 random letters in its still goes to the if statement and not the else.
pls reply as fast as you can this is due tomorrow. its ok if you don’t.
Great series Sentdex, you helped me learn python over a weekend! General question, how do you make a new column and have an if-then statement in the new column? Example, I have two columns with different string lengths and I want a new column that will use either column if the length of the string is 13.
I once had a girlfriend named Elif.
How can you do this with variables that have an input e.g.
understand = input(‘is that understood?’)
if understand == yes
print(‘good, now lets move on’)
Thanks for the tutorials!
How x is greater than 55 when x is 5 you dumm dumm
I have doneif phone=android: print (“yay”)what is wrong?? please help