if not isinstance(name, str):
return 'The character name should be a string'
if not name:
return 'The character should have a name'
if len(name)>10:
return 'The character name is too long'
if " " in name:
return 'The character name should not contain spaces'
stats = \[strength, intelligence, charisma\]
if not all(isinstance(stat, int) for stat in stats):
return 'All stats should be integers'
if any(stat<1 for stat in stats):
return 'All stats should be no less than 1'
if any(stat>4 for stat in stats):
return 'All stats should be no more than 4'
if sum(stats) != 7:
return 'The character should start with 7 points'
def stat_bar(value):
return full_dot\*value + empty_dot\*(10-value)
result = (f"{name}\\\\n" + f"STR {stat_bar(strength)}\\\\n" + f"INT {stat_bar(intelligence)}\\\\n" + f"CHA {stat_bar(charisma)}")
return result
I am having issue with `RPG step 11 and 12.`
```
full_dot = '●'
empty_dot = '○'
def create_character(name,strength,intelligence,charisma):
if not isinstance(name, str):
return 'The character name should be a string'
if not name:
return 'The character should have a name'
if len(name)>10:
return 'The character name is too long'
if " " in name:
return 'The character name should not contain spaces'
stats = [strength, intelligence, charisma]
if not all(isinstance(stat, int) for stat in stats):
return 'All stats should be integers'
if any(stat<1 for stat in stats):
return 'All stats should be no less than 1'
if any(stat>4 for stat in stats):
return 'All stats should be no more than 4'
if sum(stats) != 7:
return 'The character should start with 7 points'
def stat_bar(value):
return full_dot*value + empty_dot*(10-value)
result = (f"{name}\\n" + f"STR {stat_bar(strength)}\\n" + f"INT {stat_bar(intelligence)}\\n" + f"CHA {stat_bar(charisma)}")
return result
print(create_character('ren', 4, 2, 1))
```
Output `` ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○``` if i use \n it is giving me same error and it give output in new line which shows in example. i tried following :
Thank you for assistance. Today before it was not working and i was getting output same as shown in example. Now my code is working with \n . Appreciate your help