roman-numerals

How or when is a variable updated?

How or when is a variable updated? Question: I wrote this code (spoilers for LeetCode problem 13): roman_numbers = [(‘I’, 1), (‘V’, 5), (‘X’, 10), (‘L’, 50), (‘C’, 100), (‘D’, 500), (‘M’, 1000)] class Solution: def get_value(self, number): return dict(roman_numbers)[str(number)] def romanToInt(self, s: str) -> int: result = 0 letter_list = list(letter for letter in …

Total answers: 2

Having trouble with a function that has to split a string into roman numbers weights

Having trouble with a function that has to split a string into roman numbers weights Question: i wrote this code: admitted_List = [1, 5, 10, 50, 100, 500, 1000] tempString = "" finalList = [] for i in range(len(xkcd)-1): if int(xkcd[i] + xkcd[i+1]) in admitted_List: tempString += xkcd[i] continue else: tempString += xkcd[i] finalList.append(int(tempString)) tempString …

Total answers: 2