Python Forum
A function for correctly using "a/an" before a word
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A function for correctly using "a/an" before a word
#1
I want to make a function that, when passed a string containing a single word, returns that word preceded by the indefinite article "a" or "an," depending on which is correct. This would be easy enough to do if the rule we were taught as kids were correct: "a" before a consonant, "an" before a vowel. But it isn't. It's "a" before a consonant sound and "an" before a vowel sound; hence, "an umbrella" but "a unicorn" (YOO-ni-corn). How would you go about writing this function? Would you try to compile an exhaustive list of "exceptions" from online sources or work with some kind of API or what? Also, how would you find out if someone has already done this?
Reply


Messages In This Thread
A function for correctly using "a/an" before a word - by Exsul1 - Oct-07-2019, 05:51 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Brick Have I implemented this function correctly? naggafin 4 2,314 May-22-2022, 02:52 AM
Last Post: stevendaprano
Question Problem: Check if a list contains a word and then continue with the next word Mangono 2 2,487 Aug-12-2021, 04:25 PM
Last Post: palladium
  Python Speech recognition, word by word AceScottie 6 15,983 Apr-12-2020, 09:50 AM
Last Post: vinayakdhage
  print a word after specific word search evilcode1 8 4,813 Oct-22-2019, 08:08 AM
Last Post: newbieAuggie2019
  Python function that uses a word as the encryption key, rather than an integer wak_stephanie 4 4,829 Aug-31-2018, 12:16 PM
Last Post: perfringo
  difference between word: and word[:] in for loop zowhair 2 3,662 Mar-03-2018, 07:24 AM
Last Post: zowhair

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020