Hello guys i have been trying to make this program so their are no glitches or cheats in it. I just can not figure our how to use a while loop on line [] so that if nothing is entered the program does not continue to operate.
#Running pertty good but needs work!
#charector creator program v3
#values
def getString(prompt):
result = input(prompt)
while len(result) == 0:
result = input(prompt)
return result
def Character_Creator_Function():
NAME = getString("Please enter your name: ")
if (input("Would you like instructions?(y,n): ") in ['y','Y']):
printInstructions()
print("Welcome",NAME)
stats=[NAME, "HP", "STR", "AC", "DAM" "LCK", "DEF"]
HP=0
STR=0
AC=0
DAM=0
LCK=0
DEF=0
#interface begins
op=31
points=30
choice=None
print("Welcome to the Charector Creater Program!")
while choice!="0":
print("\nYou have",points,"points to spend on various stats!")
#list below
print(
"""
1= Add points
2= Take away points
3= View Stats
4= Begin Battle!
""")
choice=input("choice:")
#choice 1
if choice=="1":
stats=input("""
1- Health Points
2- Strenght Points
3- Armor Class Points
4- Damage Points
5- Luck Points
6- defense Points
""")
add=int(input("how many points?"))
if add<=points and add>0:
if stats=="1":
HP+=add
print( HP, "= Health points.")
elif stats=="2":
STR+=add
print( STR, "= Strenght points.")
elif stats=="3":
AC+=add
print( AC, "= Aromor Class points.")
elif stats=="4":
DAM+=add
print( DAM, "= Damage points.")
elif stats=="5":
LCK+=add
print( LCK, "= Luck points.")
elif stats=="6":
DEF+=add
print( DEF, "= defense points.")
points-=add
print("you have", points)
else:
print("""
Invalid answer!
You either do not have enought points.
OR
You are entering a negitive number!
""")
#choice 2
if choice=="2":
stats=input("""
1- Health Points
2- Strenght Points
3- Armor Class Points
4- Damage Points
5- Luck Points
6- defense Points
""")
take=input("how many points?")
while take==0:
if stats=="1" and take<=HP:
HP-=take #HP
print( HP, "= Health points.")
elif stats=="2" and take<=STR:
STR-=take #STR
print( STR, "= Strenght points.")
elif stats=="3" and take<=AC:
AC-=take #AC
print( AC, "= Aromor Class points.")
elif stats=="4"and take<=DAM:
DAM-=take #DAM
print( DAM, "= Damage points.")
elif stats=="5"and take<=LCK:
LCK-=take #LCK
print( LCK, "= Luck points.")
elif stats=="6"and take<=DEF:
DEF-=take #DEF
print( DEF, "= Defense points.")
points+=take
else:
print("""
Invalid answer!
You are do not have that many points!
""")
#choice 3
if choice=="3":
print("Health:", HP)
print("Strenght:", STR)
print("Armor Class:", AC)
print("Damage:", DAM)
print("Luck:", LCK)
print("Defense:", DEF)
#choice 4
if choice=="4":
print("You have Compleated your Charector creator program! Congradulations! you are now ready to begin battle! HuRa!")
print("HP:",HP,"\nSTR:",STR,"\nAC:",AC,"\nDAM:",DAM,"\nLCK:",LCK,"\nDEF:",DEF ,"\n")
return [NAME,HP,STR,AC,DAM,LCK,DEF]
#for programmers use to navagate through out the program with ease
if choice=="x":
HP=1000
STR=10
AC=5
DAM=10
LCK=100
DEF=5
print("HP:",HP,"\nSTR:",STR,"\nAC:",AC,"\nDAM:",DAM,"\nLCK:",LCK,"\nDEF:",DEF ,"\n")
print("You have Compleated your Charector creator program! Congradulations!")
print("You are now ready to begin battle! HuRa!\n\n")
return [NAME,HP,STR,AC,DAM,LCK,DEF]
Character_Creator_Function()
this is the error i am getting:
Traceback (most recent call last):
File "/Users/alexmasse/Desktop/ExampleQuest final/Charector Creator 100% functions, NOT IDEAL.py", line 145, in <module>
Character_Creator_Function()
File "/Users/alexmasse/Desktop/ExampleQuest final/Charector Creator 100% functions, NOT IDEAL.py", line 49, in Character_Creator_Function
add=int(input("how many points?"))
ValueError: invalid literal for int() with base 10: ''
on line 49 i do need the int(input("yadayadyad")
because if i don't have the int input it gives me a int>str can not do or some weird error like that.
PLEASE HELP!
ps. I'm fairly new to programming so could you use code to an extent and the translate into laymen's terms sort to speak, thank you :)