Ad
  • Default User Avatar

    Thanks a lot, still learning python and this came as a great painkiller.

  • Default User Avatar

    Example test harness, hope this helps:

    
    class RomanNumerals:
        def __init__(self, value):
            self.value = value
        @classmethod
        def to_roman(self,s):
            pass
        @classmethod
        def from_roman(self,s):
            pass
    
  • Custom User Avatar

    I posted my code in a separate comment, wondered if you might be able to help me! I'm getting that same unbound error, but my methods (I thought) were bound inside my class definition. How is Codewars trying to instantiate the RomanNumerals object when they test my code?

  • Custom User Avatar

    Any idea on how the "Submit" button tries to instantiate the class object we write? Here's my code, any help appreciated!

    class RomanNumerals():
    
        def __init__(self, value):
            self.value = value
    
        def to_roman(self):
            '''method that works'''
        
        def from_roman(self):
            '''method that works'''
    

    Here are my test cases, which I pass.

    my_num = RomanNumerals(1000)
    test.assert_equals(my_num.to_roman(), 'M')
    test.assert_equals(my_num.from_roman(), 1000)
    my_num = RomanNumerals(1969)
    test.assert_equals(my_num.to_roman(), 'MCMLXIX')
    test.assert_equals(my_num.from_roman(), 1969)

  • Custom User Avatar

    In python, getting a NameError on the test case when it's looking for 'err'.