I am a not an experienced programmer so please bear with me.I have been trying to solve this problem for hours to no avail. I would really appreciate a solution to my problem.
Create a program that will:
- reverse the order of a list if the list consists of integers alone
- Will convert the list items to uppercase if the list contains words only.
- Will return the same list if the list members don’t satisfy either of these two criteria
Edit: This question is a duplicate
Here is my test code:
import unittest
import switchreverse
class Reverser(unittest.TestCase):
def test_Reverse(self):
word_lists = [1,2,3,4,5]
for e in word_lists:
if type(0):
assert word_lists.reverse()
if type(''):
assert word_lists.upper()
else:
return word_lists
if __name__ == '__main__':
unittest.main()
Here is the code being tested:
def Switchreverser():
word_lists = [1,2,3,4,5]
for e in word_lists:
if type(0):
word_lists.reverse()
elif type(''):
word_lists.upper()
else:
return word_lists
Here is the error I am recieving:
F
======================================================================
FAIL: test_Reverse (__main__.Reverser)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test_switchreverse.py", line 8, in test_Reverse
assert word_lists.reverse()
AssertionError
----------------------------------------------------------------------
Ran 1 test in 0.000s
FAILED (failures=1)