Tell us what’s happening:
What’s wrong with code?I am unable to resolve the error..please help.
Your code so far
full_dot = '●'
empty_dot = '○'
def create_character(s,strn,intl,cha):
if not isinstance(s,str):
return "The character name should be a string"
elif len(s)==0:
return "The character should have a name"
elif len(s)>10:
return "The character name is too long"
for i in range(0,len(s)):
if(s[i]==" "):
return "The character name should not contain spaces"
if all(not isinstance(v,int) for v in(strn,intl,cha)):
return "All stats should be integers"
elif (strn and intl and cha)<1:
return "All stats should be no less than 1"
elif (strn and intl and cha)>4:
return "All stats should be no more than 4"
elif strn+intl+cha!=7:
return "The character should start with 7 points"
else:
return (s,f"\nSTR {full_dot*strn}{empty_dot*(10-strn)}\nINT{full_dot*intl}{empty_dot*(10-intl)}\nCHA{full_dot*cha}{empty_dot*(10-cha)})
p=create_character('ren',4,2,1)
print(p)
Your browser information:
User Agent is: Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Mobile Safari/537.36
Challenge Information:
Build an RPG Character - Build an RPG Character