Python program to calculate GCD def gcd(a,b):
    if (a&gt;b):
        r1=a
        r2=b
    else:
        r1=b
        r2=a   
    if(r1%r2==0):
        print (r2)
    else:
        gcd(r2, r1%r2)
a= int(input("Enter a number"))
b= int(input("Enter a number"))
gcd(a,b)


This code is about finding the greatest common divisor of two numbers. 
Are there any better methods?
How can I improve this code?
Bug: 

When I input -6 and -3 I expect the result to be 3 but  I get a RecursionError exception instead:

RecursionError: maximum recursion depth exceeded in comparison

For the sake of UX:


Leave some space between the text you display and the data to input:

Enter a number6
Enter a number5


This would be the minimum better:

Enter a number: 6
Enter a number: 5

You know what your program does, but not the user, so your messages must be clear and precise. Ask the user not to input a number but an integer number. Otherwise this can mislead the user to input a real number, or input a character by mistake (or even try to break into your software):

Traceback (most recent call last):
  File "cr.py", line 12, in &lt;module&gt;
    a= int(input("Enter a number"))
ValueError: invalid literal for int() with base 10: 'g'

Your program does not give a choice for the user to exit. The minimum you can do for this purpose is to handle the KeyboardInterrupt exception corresponding to when the user presses Ctrl + c
The messages are intended to communicate with the user, so let him know what the programs does:

print('Computing the GCD of two numbers.\n')


Divide and conquer:

This is a consequence of the aformentioned: it is time to implement a function whose only purpose is care about the user's input:

def read_an_integer_user_input():
    a = None   
    while type(a) != int:
        try:
            a = int(input('Enter an integer: '))
        except ValueError:
            print('I expect an integer value. Try again.')
        except KeyboardInterrupt:
            print('\nGoodbye!')
            break
    return a

Do not print, return:

We expect the function that computes something to return the result not to print it. Not only this is the function definition by essence, but this way you give more chance for your code to be reused and properly. So instead of coding print(r2) I would write return r2; by the way, do not leave space between  print and (.
Iterative version:

Given the recursion bug previsouly mentioned, I would opt for an iterative implementation of your code:

def compute_gcd(a,b):
    a = abs(a)
    b = abs(b)
    while b:
        a, b = b, a%b
    return a



Full program:

Let us gather the elements above to build a small coherent program:

def compute_gcd(a,b):
    a = abs(a)
    b = abs(b)
    while b:
        a, b = b, a%b
    return a

def read_an_integer_user_input():
   a = None   
   while type(a) != int:
       try:
           a = int(input('Enter an integer: '))
       except ValueError:
           print('I expect an integer value. Try again.')
       except KeyboardInterrupt:
           print('\nGoodbye!')
           break
   return a

if __name__ == '__main__':
    print('Computing the GCD of two numbers.')
    a = read_an_integer_user_input()
    b = read_an_integer_user_input()
    if a and b:       
       print('The GCD of {} and {} is: {}'.format(a, b, compute_gcd(a, b)))