if语句的双分支

以前接触的语句,if,for,not

age_of_you = 25
if age_of_you > 25:
print("time to find a bf.")
else:
print("还可以再谈几次恋爱。。。")
print("----hhahh")

前俩个print在条件中达到才打印其中一个,很重要很重要,对齐方式

最后一个print两种情况都会打印,


下面的我必须名字,密码全输对,才welcome。。。,不然就wrong。。。
if使用中and的用法,就是两个条件一起满足啦,电路中的与或非门一样的
_username = "shanshan"
_password = "abc123"
username = input("username:")
password = input("password:")

if username == _username and password == _password:
print("welcome",_username)
else:
print("wrong username or password!")




猜你喜欢

转载自www.cnblogs.com/muncihlai/p/9425219.html
今日推荐