Build an RPG Character - Build an RPG Character

Tell us what’s happening:

OUTPUT from my coded when running in Geany
ren
STR ●●●●○○○○○○
INT ●●○○○○○○○○
CAR ●○○○○○○○○○
The character name should be a string.
The character should have a name.
The character name is too long.
The character name should not contain spaces.
All stats should be integers.
All stats should be no less than 1.
All stats should be no more than 4.
The character should start with 7 points.


(program exited with code: 0)

Your code so far

full_dot = '●'
empty_dot = '○'

def show_dots(nmbr):
    astr = full_dot * nmbr + empty_dot * ( 10 - nmbr)
    return astr

def create_character(name, strength, intelligence, carisma):
	if type(name) is not str:
		return "The character name should be a string."
	if len(name)<1 :
		return("The character should have a name.")

	
	if(len(name)>10):
		return("The character name is too long.")

		
	if(name.count(' ')>0):
		return("The character name should not contain spaces.")
		
# all stats must be integer	
	if((type(strength) != int) or 
		(type(intelligence) != int) or 
		(type(carisma) != int) ):
		return("All stats should be integers.")

# all stats must > 1 	
	if((strength <1) or (intelligence<1) or (carisma<1) ):
		return("All stats should be no less than 1.")

# All stats should be no more than 4.'
	if((strength >4) or (intelligence >4) or (carisma>4) ):
		return("All stats should be no more than 4.")

# If the sum of all stats is different than 7, 
	if strength + intelligence + carisma != 7:
		return("The character should start with 7 points.")

	return (name +
		"\nSTR "+ show_dots(strength) +
		"\nINT "+ show_dots(intelligence) +
		"\nCAR "+ show_dots(carisma))
	
#

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


print (create_character(20,3,4,5))

print (create_character("",2,3,4))

print (create_character("thunderbolt",2,3,4))

print (create_character("thunde  t",2,3,4))

print (create_character("thunde",2,"bla",4))

print (create_character("thunde",0,3,4))

print (create_character("thunde",5,3,4))

print (create_character("thunde",1,3,4))


Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:140.0) Gecko/20100101 Firefox/140.0

Challenge Information:

Build an RPG Character - Build an RPG Character

We see you have posted some code but did you have a question?

THis code does not pass the tests WHY?

Do you have any errors or messages in the console?

NO errors or messages, so???

Great!

So, what is the requirement of the first test which fails?

The character name should be a string.

That’s the requirement of the test?

Is your character name a string?

No : print (create_character(20,3,4,5))

This is the requirement of the test? Can you just share the full text of the test?

It’s this:

  1. When create_character is called with a first argument that is not a string it should return The character name should be a string.

What does your program output when the first argument is not a string?

So the first argument is 20, clearly not a string, my program prints:

The character name should be a string.

Ok, I think I see the problem.

Can you see the parts of the test which are highlighted ? Like create_character and The character name should be a string ?

The highlighted part is what you need to return. Note that the period at the end of the sentence is not highlighted.

AThanks all right full stops not wanted , text 11 and 12 are still a mystery

1 Like
ren
STR ●●●●○○○○○○
INT ●●○○○○○○○○
CHA ●○○○○○○○○○
ren
STR ●●●●○○○○○○
INT ●●○○○○○○○○
CAR ●○○○○○○○○○

“charisma”

Thanks allright, sorry, not carisma as in my mother tongue

Aha, I see! Watch out for those details in your strings, everything needs to match what the tests want exactly

Sorry cant find an appropriate link, The testt for Loops and Sequence say I have 15 out of 20 correct, but it does not let me go back and revise themk. Should I just exit the test?

do not exit the test, close the modal and look at which ones you have failed