I’ve tried all I can but I can’t get past problem 18 and 19 even though the code does what is required
Your code so far
full_dot = '●'
empty_dot = '○'
def create_character(name,strength, intelligence, charisma):
if not isinstance(name, str):
return 'The character name should be a string'
elif name == "":
return 'The character should have a name'
elif len(name) > 10 :
return 'The character name is too long'
elif ' 'in name:
return 'The character name should not contain spaces'
if not isinstance(strength,int) :
return "All stats should be integers"
if not isinstance(intelligence,int) :
return "All stats should be integers"
if not isinstance(charisma,int) :
return "All stats should be integers"
if strength < 1:
return "All stats should be no less than 1"
if intelligence < 1:
return "All stats should be no less than 1"
if charisma < 1:
return "All stats should be no less than 1"
if strength > 4:
return "All stats should be no more than 4"
if intelligence > 4:
return "All stats should be no more than 4"
if charisma > 4:
return "All stats should be no more than 4"
if (strength + intelligence+ charisma) != 7:
return'The character should start with 7 points'
stats = (name,strength,intelligence,charisma )
if not stats == True:
return name+('\nSTR' + full_dot*strength+empty_dot*(10-strength)) + ( '\nINT' +full_dot*intelligence+empty_dot*(10-intelligence))+ ('\nCHA' +full_dot*charisma+empty_dot*(10-charisma))
create_character('ren',4,2,1)
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36 OPR/127.0.0.0 (Edition ms_store)
I’m grateful for the help and the warm welcome , The problem was my understanding because for the life of me I also can’t understand what no.19 wants me to do, I put in create_character(‘ren’, 4, 2, 1) which I assume are the correct values but nothing is happening
Here, you have hard-coded the value that your specific function call is expecting. That is not solving the problem. What if you called your function like this instead? create_character('giant',3,1,3) Would your code return the correct string?
The reason was because this is what the program wanted, it actually got me past problem 18. I didn’t want to hard code it but it wouldn’t accept my other piece of code.
The reason I used, stats = (name,strength,intelligence,charisma )
if not stats == True: . was because I thought it was the only way for it to return the results of the code before it