Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def integer_to_roman_conversion(x):
- d = {1000:'M', 900:'CM', 500:'D', 400:'CD',100:'C', 90:'XC',50:'L',40:'XL',10:'X',9:'IX',5:'V',4:'IV',1:'I'}
- resp = ''
- while x>0:
- for i in d:
- if i<=x:
- resp+=d[i]
- x=x-i
- break
- return resp
- try:
- num = int(input("Enter a positive number between 0 and 1000 : "))
- while True:
- if num>0 and num<1000:
- break
- else:
- num = int(input("Enter a positive number between 0 and 1000 : "))
- print(integer_to_roman_conversion(num))
- except ValueError:
- print("The input must be a number.")
Advertisement
Add Comment
Please, Sign In to add comment