If statement not working correctly in Python 3

2024/11/17 4:41:20

This is the start of an RPG I am going to make, and It runs smoothly until I try to change the gender by saying yes or any other of the answers that activate the if statement. Is there something I am forgetting? P.S. Sorry about this. I am an amateur.

import random
import time
def Intro():print('Hit enter to begin.')input()print('Please choose a name for your character.')PlayerName=input()def KeepName():print('You have chosen "' + PlayerName + '" as your character\'s name.') print('Do you wish to keep this as your name? (yes or no)')return input().lower().startswith('n')while KeepName():print('Please choose a name for your character.')PlayerName=input()planet = 'Sykahrox VII' #Useless as of this point but I kept it in so I can remember the name of the planet.def gender():print('Do you want to be Male, or Female?')choice = input().lower()if choice in ('m', 'male', 'boy', 'guy', 'dude'):return 'Male'if choice in ('f', 'female', 'girl', 'woman'):return 'Female'ChangeGen = 'y'while ChangeGen in ('y', 'yes', 'yeah', 'yup'):genderchoice = gender()print ('You have chosen ' + genderchoice + ' as your gender. Do you wish to change this?')ChangeGen = input().lowerif ChangeGen in ('y', 'yes', 'yeah', 'yup'):gender()Intro()
Answer

The then statement of your if clause returns from the function gender(). So you never reach your second print statement in gender.

https://en.xdnf.cn/q/118845.html

Related Q&A

pymc3 error. AttributeError: module arviz has no attribute geweke [closed]

Closed. This question needs debugging details. It is not currently accepting answers.Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to repro…

how to prevent duplicate text in the output file while using for loop

I have this code which compares a number to a number(what i called item in my code) in the domain range to see if it is already there. If it its then print to the output file if it is not then only pri…

How to replace \\ with \ without raising an EOL error?

I am reading from a file that contains byte data but when I open the file and store the readline data into a variable it stores it in a string with backslash escapes, So when trying to decode that data…

How to find duplicates in pandas dataframe

Editing. Suppose I have the following series in pandas:>>>p 0 0.0 1 0.0 2 0.0 3 0.3 4 0.3 5 0.3 6 0.3 7 0.3 8 1.0 9 1.0 10 1.0 11 0.2 12 0.2 1…

i have error eol while scanning string literal

i dont know what is the problem im junior on python programer what happened on my code i study but i dnt understand this #fungsi coveragedef coverage ():print("[1] Kota Besar)print("[2] Kota…

How to extract specific data from JSON?

I cant seem to extract specific data from JSON which I retrieved from a link. I wrote this code and seems to work fine up to x [print(x) that is] as you can see from the screenshot-1. But, its giving e…

python csv: getting subset

here is a snapshot of my csv:alex 123f 1 harry fwef 2 alex sef 3 alex gsdf 4 alex wf35 6 harry sdfsdf 3i would like to get the subset of this data where the occurrence of a…

Variable within a Variable in Python (3)

My head is probably in the wrong place with this, but I want to put a variable within a variable.My goal for this script is to compare current versions of clients software with current software version…

selenium scraping data using children of elements

Hi im trying to scrape some data from a live stocks website. I want to display the companies name and stock price, %change ect. The details of 25 companies are shown per page, and these details follow …

Python - ETFs Daily Data Web Scraping

Im trying to web scrape some daily info of differents ETFs. I found that https://www.marketwatch.com/ have a accurate info. The most relevant info is the open Price, outstanding shares, NAV, total asse…