Created
September 15, 2015 13:37
-
-
Save Dineshs91/2a7de4f73f7ade7a7406 to your computer and use it in GitHub Desktop.
Convert given no into rupee representation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Money in INR(Indian Rupees) | |
def convert(no): | |
rev_no = no[::-1] | |
ans = '' | |
for index, char in enumerate(rev_no): | |
ans = char + ans | |
if index >= 2 and index % 2 == 0 and len(no) > index + 1: | |
ans = ',' + ans | |
return ans | |
print 'Input in INR:', convert('49') | |
print 'Input in INR:', convert('149') | |
print 'Input in INR:', convert('1497') | |
print 'Input in INR:', convert('14945') | |
print 'Input in INR:', convert('149999') | |
print 'Input in INR:', convert('1499994') | |
print 'Input in INR:', convert('14999942') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output
1497 => 1,497
14945 => 14,945
149999 => 1,49,999
1499994 => 14,99,994
14999942 => 1,49,99,942