Fundamentals
Strings
Fundamentals
Strings
from collections import deque def reverse_string(string): return string[::-1]
- from collections import deque
- def reverse_string(string):
reversed_str = deque("")[reversed_str.appendleft(letter) for letter in string]return "".join(reversed_str)- return string[::-1]
import codewars_test as test from solution import reverse_string @test.describe("Solution") def a(): @test.it("should test for something") def a(): test.assert_equals(reverse_string('abc'), 'cba') test.assert_equals(reverse_string('123'), '321') test.assert_equals(reverse_string('a1b2c3'), '3c2b1a') test.assert_equals(reverse_string('Hello World!'), '!dlroW olleH') test.assert_equals(reverse_string('Capre diem'), 'meid erpaC') test.assert_equals(reverse_string('Lorem ipsum dolor sit amet!'), '!tema tis rolod muspi meroL') test.assert_equals(reverse_string('abcdefghijklmnopqrstuvwxyz'), 'zyxwvutsrqponmlkjihgfedcba')
- import codewars_test as test
- from solution import reverse_string
- @test.describe("Solution")
- def a():
- @test.it("should test for something")
- def a():
- test.assert_equals(reverse_string('abc'), 'cba')
- test.assert_equals(reverse_string('123'), '321')
- test.assert_equals(reverse_string('a1b2c3'), '3c2b1a')
- test.assert_equals(reverse_string('Hello World!'), '!dlroW olleH')
- test.assert_equals(reverse_string('Capre diem'), 'meid erpaC')
test.assert_equals(reverse_string('Lorem ipsum dolor sit amet!'), '!tema tis rolod muspi meroL')- test.assert_equals(reverse_string('Lorem ipsum dolor sit amet!'), '!tema tis rolod muspi meroL')
- test.assert_equals(reverse_string('abcdefghijklmnopqrstuvwxyz'), 'zyxwvutsrqponmlkjihgfedcba')