LogFAQs > #955560150

LurkerFAQs, Active DB, DB1, DB2, DB3, DB4, DB5, DB6, DB7, Database 8 ( 02.18.2021-09-28-2021 ), DB9, DB10, DB11, DB12, Clear
Topic List
Page List: 1
TopicITT: Learning Python
SpiritSephiroth
06/29/21 11:53:53 AM
#27:


1337toothbrush posted...
First line makes a call to input() which takes a string that you want to display to the terminal and returns what the user enters into the terminal. That gets assigned to the variable characteristic.

You input "light" so now characteristic == "light". It hits the line --if characteristic == "light":-- which resolves to true, because that is what the variable is holding. However, you make a call to the print() function. print() takes in a string and writes it out to the terminal. So the next output you see is "exemplary individual".

Finally it gets out of the if-block and hits the next print statement: --print("You look like a " + characteristic)--
Remember that characteristic is still holding the value "light", which is why it prints out "You look like a light".

Instead of --print("exemplary individual")-- you should be assigning the string "exemplary individual" to a variable. The quick fix would be to reassign characteristic to that value. So replace your print statements e.g.:

print("exemplary individual") instead becomes: characteristic = "exemplary individual"


SomeLikeItHoth posted...
Like the above person said, you have two print functions going on. And actually the bottom print function isn't even needed.

characteristic = input("Please choose an alignment, Light or Dark: ").lower()

if characteristic == "light":
print("You look like an exemplary individual.")
elif characteristic == "dark":
print("You look like a foreboding character.")
else:
print("Invalid target")

Unless you're using the light/dark functions for something else, in which case you could write this.

light = "exemplary indivudual"
dark = "foreboding character"

characteristic = input("Please choose an alignment, Light or Dark: ").lower()

if characteristic == "light":
print(f"You look like an {light}.")
elif characteristic == "dark":
print(f"You look like a {dark}.")
else:
print("Invalid target")

Thanks for the help guys! I knew I was missing something obvious but my brain wasn't thinking straight for some reason. Now I can continue practicing.

---
... Copied to Clipboard!
Topic List
Page List: 1