String Manipulation



In computer science, a string is a piece of text or a collection of characters.
A string can be stored in a variable, can be typed in by the end-user (input) or can be displayed on the screen (output).

print("Hello World")

In the above Python instruction: “Hello World” is a string. Notice the use of speech marks when using a string in code.

A string can be stored in a variable for instance.

greeting = "Hello"

String Concatenation

The act of joining two strings together is called string concatenation.

In Python string concatenation is done using the + sign:

firstname = "James"
print("Hello " + firstname)

String Manipulation Techniques

In computer programs it is often necessary to manipulate strings to:

  • Extract or truncate the first few characters of a string,
  • Extract or truncate some characters at the end of the string,
  • Find out the length (number of characters) of a string,
  • Convert a string from lowercase to UPPERCASE or vice-versa,
  • Check if a character has been used in a string,
  • Find out if a string contains a specific substring or word,
  • etc.

String Manipulation Challenges

Use our Block Programming tool to complete and test some String Manipulation challenges online.


Did you like this challenge?

Click on a star to rate it!

Average rating 4 / 5. Vote count: 14

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!

Tagged with: