Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python help
#1
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)
Reply
#2
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.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Forum Jump:

User Panel Messages

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