<filename>language/python/pocket-primer/CH3 - Sequences Strings, Tuples, and Lists/reverse.py
# This program reverses a string

word = "What <NAME>? Are you inside?"

# This section goes through each element of the String and manually interchanges it
k = len(word)

reverse = word

for i in range(0, k):
    reverse = reverse + reverse[k-i-1]

reverse = reverse[len(reverse)//2:]

print("Word: " + word)
print("Reverse: " + reverse)


# This section uses string slicing
# Example:
# 
# name = "<NAME>"
#
# name_splice_two = name[::2]
# name_splice_two is equivalent to "pl rne"

print("\nReversed a string using string splicing\n")

print("Reversed using splice: " + reverse[::-1])
print("Reversed using splice: " + reverse[::-1])
<filename>language/python/pocket-primer/CH3 - Sequences Strings, Tuples, and Lists/reverse.py
# This program reverses a string

word = "What <NAME>? Are you inside?"

# This section goes through each element of the String and manually interchanges it
k = len(word)

reverse = word

for i in range(0, k):
    reverse = reverse + reverse[k-i-1]

reverse = reverse[len(reverse)//2:]

print("Word: " + word)
print("Reverse: " + reverse)


# This section uses string slicing
# Example:
# 
# name = "<NAME>"
#
# name_splice_two = name[::2]
# name_splice_two is equivalent to "pl rne"

print("\nReversed a string using string splicing\n")

print("Reversed using splice: " + reverse[::-1])
print("Reversed using splice: " + reverse[::-1])
# This program reverses a string # This section goes through each element of the String and manually interchanges it # This section uses string slicing # Example: # # name = "<NAME>" # # name_splice_two = name[::2] # name_splice_two is equivalent to "pl rne"