Python Forum
What should i do, for this code to work -> description
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What should i do, for this code to work -> description
#1
What needs to be fixed? so that the part after else works the same way as the part before it, i.e. a question is asked and an answer is given.
The second part of my question is how to loop the code after that so that when you answer "Nein" the program will restart, and when you answer "Ja" the message_J will appear. Thank you!

This is my code:
question = input('Wie heißt du?')
answer = input('Bist du Frau oder Mann?')

message_N = "GO AGAIN BOYS!!!"
message_E = "Nein"
message_J = "Too bad, lmao"
message_f = f"Sehr geehrte Frau {question},\nIch grüße dich!"
message_m = f"Sehr geehrter Herr {question}, \nIch grüße dich!"


if question == str():
    print(answer)
if answer == "Mann":
    print(message_m)
elif answer == "Frau":
    print(message_f)
else:
    answer == input('Bist du jemanden anderer?')
    print(answer)
if answer == "Ja":
    print(message_J)
elif answer == "Nein":
    print(message_N)**


This is my output:
Output:
C:\Users\zahar\PycharmProjects\Shrek\venv\Scripts\python.exe C:/Users/zahar/PycharmProjects/Shrek/name.py Wie heißt du?asd Bist du Frau oder Mann?asd Bist du jemanden anderer?Ja asd Process finished with exit code 0
Reply


Messages In This Thread
What should i do, for this code to work -> description - by hamad - Nov-18-2021, 09:04 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Get file description Raysz 2 568 Nov-25-2023, 03:46 PM
Last Post: Raysz
  hi need help to make this code work correctly atulkul1985 5 841 Nov-20-2023, 04:38 PM
Last Post: deanhystad
  newbie question - can't make code work tronic72 2 727 Oct-22-2023, 09:08 PM
Last Post: tronic72
  Beginner: Code not work when longer list raiviscoding 2 858 May-19-2023, 11:19 AM
Last Post: deanhystad
  Why doesn't this code work? What is wrong with path? Melcu54 7 1,879 Jan-29-2023, 06:24 PM
Last Post: Melcu54
  Code used to work 100%, now sometimes works! muzicman0 5 1,507 Jan-13-2023, 05:09 PM
Last Post: muzicman0
  color code doesn't work harryvl 1 928 Dec-29-2022, 08:59 PM
Last Post: deanhystad
  Something the code dont work AlexPython 13 2,332 Oct-17-2022, 08:34 PM
Last Post: AlexPython
  Why is the 'meta description' html tag not translated? Melcu54 2 997 Oct-15-2022, 10:55 PM
Last Post: Larz60+
  cannot get code to work Led_Zeppelin 10 2,516 Jun-30-2022, 06:28 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020