I have a weird behaviour of Python that is probably pretty rational, but I don't understand it. look at this code here:
def changeDict(status):
hotstatus = status
for e in hotstatus:
if hotstatus[e]:
hotstatus[e] = "Successful"
else:
hotstatus[e] = "Failed"
print(hotstatus)
message = f"""
Operation start: {hotstatus["operation-start"]}
Operation stop: {hotstatus["operation-stop"]}
"""
return message
def initalDict():
status = {}
status["operation-start"] = True
status["operation-stop"] = False
print(status)
message = changeDict(status)
print(message)
print(f"This is the status: {status}")
initalDict()
How does this output come from this:
{'operation-start': True, 'operation-stop': False}
{'operation-start': 'Successful', 'operation-stop': 'Failed'}
Operation start: Successful
Operation stop: Failed
This is the status: {'operation-start': 'Successful', 'operation-stop': 'Failed'}
Shouldn't the last line still read True and False as the values? I am very confused. It would be great if someone could help me with that mystery :D.
Kind regards