Lost on part with Python loops with a function to roll combined value of dice
Question: I have to create a function of two randomly rolled dice the return the
combined value. Then I have to use a loop to to roll it to give me five
different combined values.

The point I keep getting stuck at is defining the loop in terms of the
combined roll to get an out come.

I just keep getting the sequence 1 22 333 4444 55555

If you have any suggestions or help its greatly appreciated. Thank you.

Heres the code I've worked out so far

    
    
    import random
    
    def point():
        rollone = random.randint(1, 6)
        rolltwo = random.randint(1, 6)
        combined_value = dicesum(rollone, rolltwo)    
    
    
    def dicesum(x, y):
        result = x + y
        return result 
    
    
    for result in range(1,6):
        for dicerolls in range(result):
            print(result, end='')
        print()
    point()
    


Answer: Your `point` method doesn't return anything after it sums the results. See the
below code.

    
    
    import random
    
    def point():
        rollone = random.randint(1,7)         # sample (1,7) to get values from 1 to 6
        rolltwo = random.randint(1,7)
        combined_value = rollone + rolltwo    # don't need a helper just to add these
        return combined_value                 # return the combined value
    
    def main():
        for roll in range(5):
            print "Roll", roll, "Sum", point()
    

Testing

    
    
    >>> main()
    Roll 0 Sum 6
    Roll 1 Sum 2
    Roll 2 Sum 5
    Roll 3 Sum 7
    Roll 4 Sum 12
    

