Coding Assignments ( Python String )- Problems and Solutions
This article contains coding exercises related to python string
PROBLEM 1
Given a string consisting of words separated by spaces. Determine how many words it has?
Example input
Hello world
Example output
2
PROBLEM 2
Given a string, cut it into two equal parts. If the length of the string is odd, leave the middle character within the first chunk, so that the first string contains one more character than the second. Now print a new string on a single row with the first and second halves swapped: second half first and the first half last.
Example input
Qwerty
Example output
rtyQwe
PROBLEM 3
Given a string, delete all the characters @ from this string.
Example input
Example output
Bilbo.Bagginsbagend.hobbiton.shire.me
PROBLEM 4
Given a string, delete all its characters whose indices are divisible by 3
Example input
Python
Example output
yton