Elegant way to construct simple sentence for Siri to speak

I have a dictionary of items that I want Siri to speak. Is there a simple way for Siri to say ‘and’ before the last one. I keep. getting caught up with more and more complicated ways to do it. IS there a way to get the length of a dictionary and add an ‘and’ to the penultimate spot?
Thanks

There are *many* ways to do this. But much of it probably depends on your dictionary as to what might work best for you.

Unfortunately, you haven’t provided an example, so I’ll assume all keys in the root are text and valid for inclusion; but do note that dictionary content like this had no order in which they have to be read!! You should consider putting your content in a an array in the dictionary as that does maintain order by definition.

If you are familiar with regular expressions, I think this approach is pretty straight forward if you coerce the dictionary to a list and then operate on the list. Here I offer up by word or by dictionary value.

You can download this example here.

https://www.icloud.com/shortcuts/86276402fe89406d885762233922018e

Hope that helps.

3 Likes

YES! yes this. I didn’t even think about a regex. Thank you! I added “\n” to only insert the and if there are multiple lines! works great and it is so simple.