Python Forum
python help - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: python help (/thread-3928.html)



python help - ython_skyy - Jul-08-2017

I'm trying to make the gender and the class come up
print ("so you are a %s,%s and you are a level 0") %(gender ,_class) Wall

some code:
_class = input("swordsman,bowman,or wizard")
if _class == "swordsman" or _class == "wizard" or _class == "bowman":
print(" valid class")
else:
print("not valid")
gender = input("would you like a female or a male character")
if gender == "female" or gender == "male":
print("""welcome to gyp,the goal of this game is to waste your time so please don't rage quit cause python doesn't save your data.
I hope you like RPGs cause this is one of those.right now the game has five levels and I bet the creator will make more
so get ready and please enjoy...""")
else:
print("say what I understand man!!!")
print("so you are a %s,%s and you are a level 0") % (gender, _class)


RE: python help - ichabod801 - Jul-08-2017

Please use python tags. See the BBCode link in the tutorials in my signature.

If you want to use the % operator for string formatting, you need to have it inside the parenthesis for the print call:

print("so you are a %s, %s and you are level 0" % (gender, _class))
You might want to look into the format method of strings:

print("so you are a {}, {} and your are level 0".format(gender, _class))
You might also note that your check for a valid class doesn't really do anything. And you might want to check out the text adventure tutorial link in my signature.