Build an RPG Character - Build an RPG Character

Tell us what’s happening:

Need help with RPG character project. cannot figure out how to pass the last two steps. Also having difficult time understanding logic sequence and equation for stats. After getting insight from several tutorials Ive started to understand what the project is trying to get the computer to do but still foggy:

str_line = ‘STR’ + full_dot * strength + empty_dot * (10 - strength)
int_line = ‘INT’ + full_dot * intelligence + empty_dot * (10 - intelligence)
cha_line = ‘CHA’ + full_dot * charis

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'
    
    if len(name) == 0:
        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]
    
    for stat in stats:
        if not (isinstance(stat, int)):
            return 'All stats should be integers'    
        if stat < 1:
            return 'All stats should be no less than 1'       
        if stat > 4:
            return 'All stats should be no more than 4'    
    if sum(stats) != 7:
            return 'The character should start with 7 points'

    str_line = 'STR' + full_dot * strength + empty_dot * (10 - strength)
    int_line = 'INT' + full_dot * intelligence + empty_dot * (10 - intelligence)
    cha_line = 'CHA' + full_dot * charisma + empty_dot * (10- charisma)
  
    return f'{name}\n{str_line}\n{int_line}\n{cha_line}'


create_character('ren', 4, 2, 1)
print(create_character)

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36 Edg/146.0.0.0

Challenge Information:

Build an RPG Character - Build an RPG Character

if you want to see what your function return, you need to have a function call inside your print, like print(create_character('ren', 4, 2, 1))

if you do that you can see that your function output is

ren
STR●●●●○○○○○○
INT●●○○○○○○○○
CHA●○○○○○○○○○

the requested output is

ren
STR ●●●●○○○○○○
INT ●●○○○○○○○○
CHA ●○○○○○○○○○

do you see the difference?

I do not understand. When I run this code in VS code the output is that?

I have updated the code to print(create_character(‘ren’, 4, 2, 1)) and it is still giving error

aaaahhhhh… i see the difference now! Thank you!!

glad you managed to figure it out!

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.