input_strings = ["hello i am from denmark",
"that was in the united states",
"nothing here"]
dict_x = {"denmark" : "dk", "germany" : "ger", "norway" : "no", "united states" : "us"}
output_strings = []
for string in input_strings:
for key, value in dict_x.items():
if key in string:
output_strings.append(value)
break
else:
output_strings.append(string)
print(output_strings)