I am attempting to have my program iterate over a user-inputted string and print it again, with a "u" in place of every uppercase letter, an "l" in place of every lowercase letter, and a "-" in place of any other character. This is what I have written:
txt = input()
modified_txt = ""
for char in txt:
if char.isupper():
modified_txt + "u"
elif char.islower():
modified_txt + "l"
else:
modified_txt + "-"
print(modified_txt)
For some reason, my output is a blank line, as though the variable "modified_txt" was never affected by the for loop. I'm sure there's a straightforward reason why this is the case but I'm at a loss.
strings are immutable, meaning you can't modify them like this, you can tho use+=to reassign and add a character, somodified_txt += "u"and so on (it's equivalent tomodified_txt = modified_txt + "u")