Dog has 1 'friend' instead of 'friends'?

Hi everyone,

Is it possible to nest a conditional if/else statement within a string without complicating the code? For example, to say Bruno has 1 ‘friend’ instead of 1 ‘friends’:
image

image

Can I do it this way? (see highlighted section)
image

I’m also thinking of situations where there could be a lot of conditionals within a string, especially if it’s a complex sentence (think multiple singular/plural conditionals, or ‘a’/‘an’, or if coding for another language using different possible tenses, e.g. ‘appelle/appellent/appelons’) - is there a simpler way to write this conditional?

Thanks in advance!

You could use the shorter syntax for conditionals:
print("friend" if len(self.friends) == 1 else "friends")

friends = ["Sally", "Mike", "Patty"] print("friend" if len(friends) == 1 else "friends")