Redact the access code
Every login at the ground station goes into the security log, and the first version of the logger wrote the full access code into it. Anyone who could read the log could log in.
Mask the code so only its last four characters show, the way bank cards are printed on receipts, then do it inside a real log line.
Finish stage 1 to unlock this stage.
Replace every character of the access code except the last four with *, then print it:
Access code: **********77AB
You need as many stars as there are characters before the last four: len(access_code) - 4. "*" * 3 is "***", and access_code[-4:] is the last four characters.
Finish stage 1 to unlock this stage.
In the real log, the code sits inside a line, after code= and up to the next space. Find it, mask it the same way, and print the line with the masked code in its place:
AUTH ok station=Esrange code=**********77AB operator=2
line.find(" ", start) searches for a space starting at index start, so it finds the space after the code, not the first one in the line. Then line.replace(code, masked) builds the new line.
Hints
String Indexing and Slicing
# String indexing - every character has a position, counting from 0
mission = "ARTEMIS"
# 0123456
# Grabbing individual characters
print("First letter:", mission[0]) # A
print("Last letter:", mission[-1]) # S
# Slicing [start:stop] - stop is NOT included
print("First three:", mission[0:3]) # ART
print("From index 4 on:", mission[4:]) # MIS
print("Last three:", mission[-3:]) # MIS
# Step slicing [start:stop:step]
launch_code = "A1B2C3D4"
print("Every 2nd:", launch_code[::2]) # ABCD
print("The digits:", launch_code[1::2]) # 1234
# Reversing with a negative step
print("Reversed:", mission[::-1]) # SIMETRA
Separate arguments with commas. They're passed on every Run as sys.argv[1:].