-
Description Made it shorter
removed the i variable and just directly printing the index also directly printing the reversed list
Code def print_String(): # Printing the index of a string in the list. lst = ['double', 'switch', 'off', 'on', 'jump'] print (lst.index('double')) # Reversing the items in the list print ('Reversed List:',lst.reverse())
Test Cases import codewars_test as test # TODO Write tests import solution # or from solution import example # test.assert_equals(actual, expected, [optional] message) .describe("Example") def test_group(): .it("test case") def test_case(): test.assert_equals(1 + 1, 2)
Output:
-
Code - def print_String():
- # Printing the index of a string in the list.
- lst = ['double', 'switch', 'off', 'on', 'jump']
i = lst.index('double')print (i)- print (lst.index('double'))
- # Reversing the items in the list
lst.reverse()print ('Reversed List:', lst)- print ('Reversed List:',lst.reverse())
- All
- {{group.name}} ({{group.count}})
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}