18 lines
718 B
Python
18 lines
718 B
Python
# Basic example of formatting output printed to the console
|
|
|
|
# Get the user's name
|
|
name = input("What is your full name?: ")
|
|
# Print a blank line
|
|
print()
|
|
|
|
# Show the user what they typed
|
|
print(f"Your name is: {name}")
|
|
# Here we will do the "if" conditional. A conditional means
|
|
# "compare these things" and "if" means "does this whole thing evaluate to True".
|
|
# In this case we are using the string function/method (see below)
|
|
# to try and find a space character in the name and print a message if not found.
|
|
# "-1" here means "not found"
|
|
# Find method: https://www.w3schools.com/python/ref_string_find.asp
|
|
if name.find(" ") == -1:
|
|
print("You seem to have only entered a single name. Are you a rock star?")
|
|
print() |