In a modify task you take code that has already been started and adapt it so that it does what it should.
A school needs a system that automatically generates a username for each student. A programmer has started the code, but left gaps where the string slicing and the case conversion should go. Every gap is marked with question marks:
print("Enter student first name:")
first_name = input()
print("Enter student last name:")
last_name = input()
first_initial = first_name[????]
username = ???????
print("Generated username: " + ???????)
The editor starts you off with this code. It does not run as it stands: Python stops at the first line of question marks.
Modify the program so that it:
Generated username: .Keep the two questions exactly as they are. The case conversion can go anywhere before the username is built, as long as both names end up in small letters.
The two questions first, worded exactly like this:
Enter student first name:
Enter student last name:
Then one line, where USERNAME is the first letter of the first name followed
by the whole last name, all in lower case:
Generated username: USERNAME
Input:
Ada
Lovelace
Output:
Enter student first name:
Enter student last name:
Generated username: alovelace
Input:
ALAN
TURING
Output:
Enter student first name:
Enter student last name:
Generated username: aturing
Anything else in the last name stays in: Tim and Berners-Lee give
tberners-lee.
Make sure that you check for the following things:
lower() gives back a new string, so its result is stored, as in
first_name = first_name.lower().print outputs the username, not the first name or the initial.