Add ternary description
This commit is contained in:
parent
ad45ec3477
commit
b174c40fd7
|
@ -15,4 +15,12 @@ print(f"Your name is: {name}")
|
||||||
# Find method: https://www.w3schools.com/python/ref_string_find.asp
|
# Find method: https://www.w3schools.com/python/ref_string_find.asp
|
||||||
if name.find(" ") == -1:
|
if name.find(" ") == -1:
|
||||||
print("You seem to have only entered a single name. Are you a rock star?")
|
print("You seem to have only entered a single name. Are you a rock star?")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
# Many programming languages include a "ternary" operator/conditional
|
||||||
|
# This is used to return one value if a conditional evaluates to True
|
||||||
|
# or a different value if the conditional evaluates to False.
|
||||||
|
# This is especially useful when inside another function or statement.
|
||||||
|
# Usage: my_var = "Yes!" if a == b else "No!"
|
||||||
|
height = 73
|
||||||
|
print("You are", " not" if height <= 71 else "", " tall!", sep='')
|
Loading…
Reference in New Issue
Block a user