Tell us what’s happening:
Why is my code printing “[object Object]” at the end of every line? I tried running the exact same code through an IDLE editor and it worked as expected. What’s making freeCodeCamp print it differently?
Your code so far
full_dot = '●'
empty_dot = '○'
def create_character(name, strength, intelligence, charisma):
# Check character name
if type(name) is str:
if len(name) <= 10:
if " " in name:
return "The character name should not contain spaces"
else:
return "The character name is too long"
else:
return "The character name should be a string"
# Check stats
if type(strength) is int and type(intelligence) is int and type(charisma) is int:
if strength < 1 or intelligence < 1 or charisma < 1:
return "All stats should be no less than 1"
else:
if strength > 4 or intelligence > 4 or charisma > 4:
return "All stats should be no more than 4"
else:
if strength+intelligence+charisma != 7:
return "The character should start with 7 points"
else:
return "All stats should be integers"
# Loop for generation
print(name)
print("\nSTR", end=" ") # Strength loop
for x in range(strength):
print(full_dot, end="")
for x in range(10-strength):
print(empty_dot, end="")
print("\nINT", end=" ") # Intelligence loop
for x in range(intelligence):
print(full_dot, end="")
for x in range(10-intelligence):
print(empty_dot, end="")
print("\nCHA", end=" ") # Charisma loop
for x in range(charisma):
print(full_dot, end="")
for x in range(10-charisma):
print(empty_dot, end="")
print(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/141.0.0.0 Safari/537.36 Edg/141.0.0.0
Challenge Information:
Build an RPG character - Build an RPG Character