import unittest # -------------------------------------------------------------- # dropping out a letter # -------------------------------------------------------------- def without(S, i) : ''' Assume that S is a string and i is a valid positive index into S. Returns a string the same as S but without the character at position i. For example, without('wonderful', 3) returns 'wonerful' ''' pass # -------------------------------------------------------------- # The Testing # -------------------------------------------------------------- class myTests(unittest.TestCase): def test1(self): self.assertEqual(without('wonderful', 3), 'wonerful') def test2(self): self.assertEqual(without('fried', 4), 'frie') def test3(self): self.assertEqual(without('gaslighting', 0), 'aslighting') def test4(self): self.assertEqual(without('ryerson', 6), 'ryerso') def test5(self): self.assertEqual(without('university', 9), 'universit') if __name__ == '__main__': unittest.main(exit=True)
import unittest
# --------------------------------------------------------------
# dropping out a letter
# --------------------------------------------------------------
def without(S, i) :
'''
Assume that S is a string and i is a valid positive index into S.
Returns a string the same as S but without the character at position i.
For example, without('wonderful', 3) returns 'wonerful'
'''
pass
# --------------------------------------------------------------
# The Testing
# --------------------------------------------------------------
class myTests(unittest.TestCase):
def test1(self):
self.assertEqual(without('wonderful', 3), 'wonerful')
def test2(self):
self.assertEqual(without('fried', 4), 'frie')
def test3(self):
self.assertEqual(without('gaslighting', 0), 'aslighting')
def test4(self):
self.assertEqual(without('ryerson', 6), 'ryerso')
def test5(self):
self.assertEqual(without('university', 9), 'universit')
if __name__ == '__main__':
unittest.main(exit=True)
Hi.
Let's move on to the code in the next step.
I have included comments in the code that will help you in understanding the code better.
Step by step
Solved in 2 steps with 2 images