Explore
Courses
Batches
Sketches
Statistics
Code a Pookkalam
Jobs
Devsprint
People
Course Creation
Create a Course
Guidelines
Resources
Support
Blogs
My Profile
About Us
Login
Sketches
1
ROMAN_TO_INTEGER(Felt excited)
By
ARJUN
Run
def roman_to_int(s): dict1 = { 'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000 } res = 0 for i in range(len(s)): if i+1
to avoid index out of range res = res-dict1[s[i]] else: res = res+dict1[s[i]] return res command = roman_to_int('MXMXCMMVIII') print(command)
Comments
Want to discuss?
Post it here, our mentors will help you out.
Login