Day 005 - Project 5 : "Which character are you?" Generator

If you have any questions, comments or issues with this project please post them here!

drink = input("Do you prefer coffee or tea? ")
if drink == “coffee”:
print(“Tea is better.”)
else:
print(“Excellent choice.”)

This was written by a Brit lolol.

Built my very first Akinator :man_genie: style game with ‘if’ statements!

https://replit.com/@JackAdem/Day-005-Project-5-Which-character-are-you-Generator?v=1

Day 5 of #Replit100DaysOfCode #100DaysOfCode.

1 Like

(This is a note mostly for me but where others can read. This is mostly just to keep me going and motivated to finish the 100 Days Of Code.)

Day 5- Day five went pretty well I would say. It was over IF and ELSE statements. I would say that I learned some new things with it. When I was testing it I learned what I was doing wrong on something before. So I am starting to get into somethings that I am learning newer about. Thank you you read this and hope you enjoy the journey.

Link To Code: https://replit.com/@Chandler0Bing/100-Days-Of-Code-Day-5#main.py

2 Likes

this is my code below, can someone please help and tell me whats wrong with it? even if i do not type Yes/yes, the code for that statement gets executed

print("==DORAEMON CHARACTER CREATOR==")
print()
print("Answer the following questions in Yes or No and we will reveal which Doraemon characer you most relate to!")
print()
s= input("Do you like studying?:")
if s == "Yes" or "yes" :
  print ("\n" "Aha! You're Dekisugi.")
else:
  print("\n" "I guess you're not Dekisugi then.")
h = input("\n" "Do you like helping others?:")
if h == "Yes" or "yes":
  print ("\n" "You might be Doraemon.")
else:
  print("\n" "Aww, you're not Doraemon either.")
sl = input("\n" "Do you like to sleep?:")
if sl == "Yes" or "yes":
  print("\n" "It seems that you're Nobita.")
else: 
  print("\n" "Then you're not Nobita")
gg= input("\n" "Do you like to sing?:")
if gg== "Yes" or "yes":
  print("\n" "You relate the most to Gian")
else:
  print("\n" "You're not Gian either")
print("You have reached the end. We hope you enjoyed!")

Please format your code by triple backticks to make it easier to read.

  1. Use .lower() instead of “or”.

Example:

a = input("Enter your name: ").lower()

if a == "omega":
  print("Cool")
  1. Your usage of “or” is incorrect.

Incorrect usage:

a = 1

if a == 1 or 2:
  print("Hello, World!")

Correct usage:

a = 1

if a == 1 or a == 2:
  print("Hello, World!")
3 Likes

Adding on to @OmegaOrbitals here, you can also do this:

if a in ("yes", "y"):
    print("You selected yes!")
3 Likes

Question:
Please teach me how to stop the program from printing ‘else’ function after the result (“You’re Korg!!”) printed

Tutorial number: Day 5

print("Marvel Movie Character Creator")
print("--")
ID1=input("Do you like hanging around? ")
if ID1=="no":
  print("Then you're not Spider-man")
  ID2=input("Do you have 'gravelly' voice? ")
  if ID2=="no":
    print("Aww,then you're not Korg")
    ID3=input("Do you often feel 'Marvelous'? ")
    if ID3=="yes":
      print("Aha! You're Captain Marvel! Hi!")
  if ID2=="yes":
    print("You're Korg!!")
if ID1=="yes":
  print("Then you're Spider-man!")
else:
  print("Hmmm maybe you're not fit to be a Hero afterall :(")

Hey @STaera, you can format your code in triple-backtick-fences like this:

```py

```

That way there will be syntax highlighting and indenting.

Also the reason why the program prints the else’s result is because… Well…
Look at the following code.

if ID2 == "yes":
    print("You're Korg!!!")
if ID1 == "yes":
    print("Then you're Spider-Man")
else:
    # this is the important part

It checks if ID2 is true, then checks if ID1 is true; else print the unwanted result.
Try this:

ID1 = input("Do you have 'gravelly' voice?")

if ID1 == "yes": 
    print("You're Korg!!!")
else:
    print("Aww you're not Korg")
    ID1 = input("Do you like hanging around?")

    if ID1 == "yes":
        print("You're Spider-Man!")
    else:
        print("Aww you're not Spider-Man")
        ID1 = input("Do you often feel 'Marvelous'?")
        
        if ID1 == "yes":
            print("Aha, you're Captain Marvel! Hi!")
        else:
            print("Maybe you're not fit to be a hero after all :(")

You don’t need to keep creating new variables; just reuse a single variable.

sorry I got the order the wrong way :c

Explanation

First, it checks if the answer is yes. If true, it does stuff; else it asks again and checks for a yes, else it asks one last time for a yes - if it is a no - only if the final one is a no will it print the fact you are not fit to be a hero.

1 Like

hey it works! i try to put ‘else’ on ID3’s column indentation so it will only applied on ID3’s answer, thanks for your explanation.

print("Marvel Movie Character Creator")
print("--")
ID1=input("Do you like hanging around? ")
if ID1=="no":
  print("Then you're not Spider-man")
  ID2=input("Do you have 'gravelly' voice? ")
  if ID2=="no":
    print("Aww,then you're not Korg")
    ID3=input("Do you often feel 'Marvelous'? ")
    if ID3=="yes":
      print("Aha! You're Captain Marvel! Hi!")
    else:
      print("Hmmm maybe you're not fit to be a Hero afterall :(")
  if ID2=="yes":
    print("You're Korg!!")
if ID1=="yes":
  print("Then you're Spider-man!")
1 Like