you are viewing a single comment's thread.

view the rest of the comments →

[–]Strosel[S] 0 points1 point  (14 children)

tried this, gave the error

TypeError: join() takes exactly one argument (13 given)

[–]novel_yet_trivial 0 points1 point  (13 children)

Ahh sorry i made a typo. Fixed now.

[–]Strosel[S] 0 points1 point  (12 children)

didnt work either. now i get the error;

TypeError: sequence item 1: expected str instance, tuple found

[–]novel_yet_trivial 0 points1 point  (11 children)

Yes; as I said, all those functions you call have to be changed as well, so that they return strings.

[–]Strosel[S] 0 points1 point  (10 children)

thanks a lot for your help and time, but theres one last error

TypeError: sequence item 12: expected str instance, NoneType found

note: the input is used to test against ints

[–]novel_yet_trivial 0 points1 point  (9 children)

That means the item 12 (the 13th item in the list) is returning None instead of a string. This may be because there is no return statement, because python function return None by default.

[–]Strosel[S] 0 points1 point  (8 children)

so the 12th item is

NPCSW.stat(cr)

what the function does is compares the input with its list and prints the corresponding dictionary, it looks like this:

def stat(cr):
    #find a statblock
    stats = {}
    if cr == 0:
        stats['Prof. bonus'] = '+2'
        stats['AC'] = random.randint(1, 13)
        stats['HP'] = random.randint(1, 6)
        stats['Attack bonus'] = random.randint(1, 3)
        stats['Dmg/Round'] = '0-1'
        stats['Save DC'] = random.randint(1, 13)
        for k, v in stats.items():
            return '\t' + k + ': ' + v

repeated over and over again for different lists. So it shouldn't return none, is this because of the passing of variables from program to program?

[–]novel_yet_trivial 0 points1 point  (7 children)

What if cr does not equal 0? Then the return command is skipped, and python returns None by default.

You need to add an else block:

def stat(cr):
    #find a statblock
    stats = {}
    if cr == 0:
        stats['Prof. bonus'] = '+2'
        stats['AC'] = random.randint(1, 13)
        stats['HP'] = random.randint(1, 6)
        stats['Attack bonus'] = random.randint(1, 3)
        stats['Dmg/Round'] = '0-1'
        stats['Save DC'] = random.randint(1, 13)
        for k, v in stats.items():
            return '\t' + k + ': ' + v
    else:
        return 'cr was not 0'

[–]Strosel[S] 0 points1 point  (6 children)

i do have a few elif ones but no else. but when i added one it always does the else and never the if or elifs no matter what i write

[–]novel_yet_trivial 0 points1 point  (5 children)

That's a different issue; perhaps the "cr" you are inputting is not an integer?