Also, your code is not scalable. Now it’s fine since you have only two elements but for best practices, you should use a dictionary, JSON file, database, or the like.
I took my liberty to modify the output a bit:
name = tracker.get_slot("name")
country = tracker.get_slot("country")
data = {
"america": "trump",
"france": "macron"
}
message = "{} belongs to {}".format(name.title(), country.title())
if country.lower() in data.keys():
leader_name = data[country.lower()]
message = message + " and leader name is {}".format(leader_name.title())
dispatcher.utter_message(text = message)
return []
Or, to stay true to your code:
name = tracker.get_slot("name")
country = tracker.get_slot("country")
data = {
"america": "Trump",
"france": "Macron"
}
message = "not found in database!"
if country.lower() in data.keys():
leader_name = data[country.lower()]
message = "{} belongs to {} and leader name is {}".format(name, country, leader_name)
dispatcher.utter_message(text = message)
return []