Strings
Strings are sequence of one or more characters in Python. Strings can be assinged to variables.
In python, strings
1) Immutable 2) Are objects that have methods associated with it.
Let us look at Python string properties through a problem statement.
Problem Statement
Test if a given string is a palindrome.
Write test - 1
def test_palindrome():
assert is_a_palindrome("ABBA") == True
assert is_a_palindrome("BOB") == True
assert is_a_palindrome("B") == TruExercise Test - 1
def test_palindrome():
> assert is_a_palindrome("ABBA") == True
E NameError: name 'is_a_palindrome' is not definedFix Test - 1
Exercise Test - 2
Fix Test - 2
Exercise Tests - 2
Refactor
Last updated
Was this helpful?