I’ve looked at the posts on the forum and I still can’t see a problem with my code, but it’s flagging tests 5, 7, 8, 9, and 10!
Your code so far
full_dot = '●'
empty_dot = '○'
def create_character(name, Str, Int, Cha):
if not isinstance(name, str):
return 'The character name should be a string'
if len(name)>10:
return 'The character name is too long'
if ' ' in name:
return 'The character name should not contain spaces'
if not isinstance(Str or Int or Cha, int):
return 'All stats should be integers'
if (Str or Int or Cha < 1):
return 'All stats should be no less than 1'
if (Str or Int or Cha > 4):
return 'All stats should be no more than 4'
if not (Str + Int + Cha == 7):
return 'The character should start with 7 points'
print(name)
print("STR" + " " + full_dot == Str + empty_dot == 10 - Str)
print("INT" + " " + full_dot == Int + empty_dot == 10 - Int)
print("CHA" + " " + full_dot == Cha + empty_dot == 10 - Cha)
create_character("ren", 4, 2, 1)
Your browser information:
User Agent is: Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36
full_dot = '●'
empty_dot = '○'
def create_character(name, Str, Int, Cha):
if not isinstance(name, str):
return 'The character name should be a string'
if len(name)>10:
return 'The character name is too long'
if ' ' in name:
return 'The character name should not contain spaces'
if not isinstance(Str, int):
return 'All stats should be integers'
if not isinstance(Int, int):
return 'All stats should be integers'
if not isinstance(Cha, int):
return 'All stats should be integers'
if (Str < 1 or Int < 1 or Cha < 1):
return 'All stats should be no less than 1'
if (Str > 4):
return 'All stats should be no more than 4'
if (Int > 4):
return 'All stats should be no more than 4'
if (Cha > 4):
return 'All stats should be no more than 4'
stats = [Str, Int, Cha]
if not sum(stats) == 7:
return 'The character should start with 7 points'
Str_dot = full_dot * Str + empty_dot * (10 - Str)
Int_dot = full_dot * Int + empty_dot * (10 - Int)
Cha_dot = full_dot * Cha + empty_dot * (10 - Cha)
print(f'{name}\nStr {Str_dot}\nInt {Int_dot}\nCha {Cha_dot}')
create_character("ren", 4, 2, 1)