Phone

+919997782184

Email

support@roboticswithpython.com

Geeks of Coding

Join us on Telegram

#1320
Bayo BelloBayo Bello
Participant

1. The entry for question one above produces a wrong answer.
The correct entry should be:

newfilenames = []
for oldfilename in filenames:
if “.hpp” in oldfilename:
newfilenames.append(oldfilename.replace(“.hpp”, “.h”))
else:
newfilenames.append(oldfilename)

print(newfilenames)
# Should be [“program.c”, “stdio.h”, “sample.h”, “a.out”, “math.h”, “hpp.out”]

Result = [‘program.c’, ‘stdio.h’, ‘sample.h’, ‘a.out’, ‘math.h’, ‘hpp.out’]

6. The entry for question 6 can be simplified using
for guest in guests:
name, age, job = guest
print(“{} is {} years old and works as {}”.format(name, age, job))