When I ask the program second time' wanna play again'? and enter 'Y' as input. It doesnt call roll_dice() function again. Instead, it prints 'you are free to leave'..
I expect the function to roll dice again which it doesnt!!
"""This program rolls a pair of dice and adds both values then asks user to guess the number and compares it to original value. If the user's roll is greater than total value of dice roll, user wins and vice versa. Also inform user""" from random import randint from time import sleep def get_user_guess(): user_guess = int(raw_input('Guess number')) return user_guess def roll_dice(): number_of_sides= int(raw_input('please enter number of sides a dice should have')) print 'Rollingaaaa....' sleep(3) first_roll= randint(1,number_of_sides) second_roll= randint(1, number_of_sides) roll_dice= first_roll + second_roll max_val= number_of_sides *2 print'The max possible value is from 1 to ' + str(max_val) my_guess= get_user_guess() print 'waiting for your luck to decide.. hehehe' if my_guess> max_val: print 'Guess invalid' return else: print'The first roll is %d' % first_roll print'The second roll is %d' % second_roll print'The total is %d ' % roll_dice if my_guess>roll_dice: print'you won' else: print'you lost' return roll_dice() sleep(2) second_ask = str(raw_input('wanna play again?')) if second_ask == 'y or Y': roll_dice() else: print'you are free to leave'