In this challenge we will use string manipulation techniques to manipulate text data.
In Python a String is a piece of text. It can contain letters, numbers and punctuation signs.
Hello my name is Bond, James Bond
Look at the following code which highlights some key string manipulation techniques:
Using the code above can you tell how to use Python to:
- Prompt the user to enter their firstname?
- Concatenate two strings together to create a longer string?
- Retrieve the first character of a string?
- Convert a string to uppercase?
- Calculate the length (number of characters) of a string?
- Convert a number into a string?
Write a program that asks the end-user to enter the following information:
- Year Group
The program should then generate the end-user’s username using the following rules:
- 2-digit year group + first letter of firstname + lastname
- The username should be all lowercase
- If the year group is in 1 digit only (e.g.: 7) then add a “0” in front to make it two digits e.g. “07”
Test your program with the following data:
|Firstname||Lastname||Year Group||Expected Output||Actual Output|