I want the code to repeat itself if the user has given invalid input. Another way to ask would be :
ans2 = input ('Do you want to continue (y/n)')
if ans2 == 'y':
#repeat the code and I don't know how to do that
if ans2 == 'n':
print ('Ok Goodbye')
exit