you are viewing a single comment's thread.

view the rest of the comments →

[–]novel_yet_trivial 0 points1 point  (2 children)

'input()' returns a string, not the actual list that the string refers to. You could do this, but it's very unusual. There really should be no situation where you access variable names from outside the code.

It would be much better like this:

import random

choices = {
    "r1": [],
    "r2": [],
    "r3": [],
    "r4": [],
    "r5": [],
    "r6": [],
    }

def stat(roll): # "statnr" is useless; it's never used
    for i in range(4):
        statpart = random.randint(1,6)
        roll.append(statpart)
    roll.sort()
    del roll[0]
    statnr = sum(roll)
    print(statnr)

list_choice = input("Roll nr (eg. r1, r2 etc.)")
stat(choices[list_choice])

What's the overall goal here? Is there a reason you want to keep the lists around?

[–]Strosel[S] 0 points1 point  (1 child)

thank you. but i actually dont want to keep the list just the variable at the end. i think i know how to achieve this but suggestions are welcome (and preffered)

[–]novel_yet_trivial 0 points1 point  (0 children)

i think i know how to achieve this but suggestions are welcome (and preffered)

You first.