How to fix this? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: How to fix this? (/thread-37218.html) |
How to fix this? - DERO - May-13-2022 Hi. So, my question is: When I ran the below code all values change to custom(as it should be), except for the last phrase. I wonder if anyone has advice on how to fix it? Any advice would be very appreciated. Thanks first_name = str (input("first name:")) sender_name = str (input("sender name:")) friend_name = str (input("friend name:")) #text first version text1 = '''Dear first_name! How are you? Everything is okay with me. I miss you! Have you seen friend_name? If so, please, tell him/her to call me. By the way congratulations on your age birthday! Some phrase regardingage. Yours sincerely, sender_name''' birt_year = int(input("birth year:")) year = 2022 some_age_phrase = str("") is_M = bool age = year - birt_year age = str(age) error = "are you joking" #replacing name to input name a = text1.replace('first_name',first_name) b = a.replace('friend_name',friend_name) c = b.replace('age',age) d = c.replace('sender_name',sender_name) #replacing friend gender to input gender #checking and replacing gender, error explanation to a user try: friend_gender = int(input("0- male 1- female:")) if friend_gender == 0: is_M = True is_M = 'him' e = d.replace('him/her',is_M) print(e) elif friend_gender == 1: is_M= False is_M ='her' e = d.replace('him/her',is_M) print(e) else: print("No such gender supported") except ValueError: print("Only numbers! 0 or 1") if 0 <= int(age) <= 17 : e.replace ("Some phrase regardingage","Next year you'll be") elif 18 <= int(age) <= 60: e.replace ("Some phrase regardingage",'You can vote now') elif 60 <= int(age) <= 110: e.replace ("Some phrase regardingage", " Hope you do not get bored on your retirement!") else: print(error)This is my output:
RE: How to fix this? - ndc85430 - May-14-2022 First question: what have you done to work out what's causing the problem? |