Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A python list of all US state abbreviations.
states = ["AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DC", "DE", "FL", "GA",
"HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD",
"MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ",
"NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC",
"SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY"]
@busterroni

This comment has been minimized.

Copy link

@busterroni busterroni commented Apr 9, 2016

Thanks for this, saved me some time :)

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented May 28, 2016

Thank you, I'm working on address standardization for Amazon order data, and they don't do any kind of validation. This is most helpful.

@gyurisc

This comment has been minimized.

Copy link

@gyurisc gyurisc commented Jul 14, 2016

Thanks. It saved me time :)

@charleycodes

This comment has been minimized.

Copy link

@charleycodes charleycodes commented Nov 17, 2016

Used this as a global variable to iterate over for PostgreSQL queries. Thank you!

@EduGord

This comment has been minimized.

Copy link

@EduGord EduGord commented Jan 29, 2017

Thanks for sharing! I have used it to complete an exercise while studying pandas.

@timle

This comment has been minimized.

Copy link

@timle timle commented Feb 24, 2017

Thanks!

@rpaguirre

This comment has been minimized.

Copy link

@rpaguirre rpaguirre commented Apr 1, 2017

You're the man!

@pganeshGapps

This comment has been minimized.

Copy link

@pganeshGapps pganeshGapps commented May 30, 2017

Thanks man, saved my time :)!

@colbych

This comment has been minimized.

Copy link

@colbych colbych commented Jul 11, 2017

Thank you!

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Aug 4, 2017

Thanks 👍

@maxu777

This comment has been minimized.

Copy link

@maxu777 maxu777 commented Oct 8, 2017

Thank you - that helps!

@wnykuang

This comment has been minimized.

Copy link

@wnykuang wnykuang commented Nov 6, 2017

Thanks, very helpful!

@sasms

This comment has been minimized.

Copy link

@sasms sasms commented Nov 13, 2017

Amazing!

@Miando

This comment has been minimized.

Copy link

@Miando Miando commented Dec 2, 2017

Cool. Thank you!

@ChuckZhu

This comment has been minimized.

Copy link

@ChuckZhu ChuckZhu commented Dec 20, 2017

Thanks

@nikevp

This comment has been minimized.

Copy link

@nikevp nikevp commented Jan 4, 2018

Gracias

@maxmadubuike

This comment has been minimized.

Copy link

@maxmadubuike maxmadubuike commented Jan 6, 2018

Thank you for this! Saved me some time.

@RonKG

This comment has been minimized.

Copy link

@RonKG RonKG commented Apr 6, 2018

Thank you! This is very handy. First thing that showed on Google 💯

@LisaFan18

This comment has been minimized.

Copy link

@LisaFan18 LisaFan18 commented Apr 21, 2018

Thanks. I am doing my homework about shiny in R. I need a U.S. state abbreviations for selectInput choices.

@majacaci00

This comment has been minimized.

Copy link

@majacaci00 majacaci00 commented Jun 7, 2018

Thank you!!!

@hlpd-pham

This comment has been minimized.

Copy link

@hlpd-pham hlpd-pham commented Jun 21, 2018

thank you

@BobBurrows

This comment has been minimized.

Copy link

@BobBurrows BobBurrows commented Jun 27, 2018

This saved Dan and I lot's time - thanks you thank you!

@guitarist600

This comment has been minimized.

Copy link

@guitarist600 guitarist600 commented Jun 27, 2018

Thank you!

@ezeagwulae

This comment has been minimized.

Copy link

@ezeagwulae ezeagwulae commented Sep 20, 2018

very helpful. thanks.

@bfine9618

This comment has been minimized.

Copy link

@bfine9618 bfine9618 commented Oct 3, 2018

awesome!

@ethanzh

This comment has been minimized.

Copy link

@ethanzh ethanzh commented Nov 15, 2018

Thanks!

@jsheedy

This comment has been minimized.

Copy link

@jsheedy jsheedy commented Nov 19, 2018

Thank you!

Here it is in lowercase, which I needed:

print([state.lower() for state in states])
['al', 'ak', 'az', 'ar', 'ca', 'co', 'ct', 'dc', 'de', 'fl', 'ga', 'hi', 'id', 'il', 'in', 'ia', 'ks', 'ky', 'la', 'me', 'md', 'ma', 'mi', 'mn', 'ms', 'mo', 'mt', 'ne', 'nv', 'nh', 'nj', 'nm', 'ny', 'nc', 'nd', 'oh', 'ok', 'or', 'pa', 'ri', 'sc', 'sd', 'tn', 'tx', 'ut', 'vt', 'va', 'wa', 'wv', 'wi', 'wy']
@ewmendez

This comment has been minimized.

Copy link

@ewmendez ewmendez commented Jan 3, 2019

Thanks!

@summonholmes

This comment has been minimized.

Copy link

@summonholmes summonholmes commented Jan 22, 2019

Thanks, I love being a lazy programmer.

@Aidan-Jared

This comment has been minimized.

Copy link

@Aidan-Jared Aidan-Jared commented Mar 8, 2019

the most beautiful thing if you are lazy

@gingercyde

This comment has been minimized.

Copy link

@gingercyde gingercyde commented Apr 9, 2019

Here is one with the abbreviations and state names!

states = ["AL - Alabama", "AK - Alaska", "AZ - Arizona", "AR - Arkansas", "CA - California", "CO - Colorado",
"CT - Connecticut", "DC - Washington DC", "DE - Deleware", "FL - Florida", "GA - Georgia",
"HI - Hawaii", "ID - Idaho", "IL - Illinios", "IN - Indiana", "IA - Iowa",
"KS - Kansas", "KY - Kentucky", "LA - Louisiana", "ME - Maine", "MD - Maryland",
"MA - Massachusetts", "MI - Michigan", "MN - Minnesota", "MS - Mississippi",
"MO - Missouri", "MT - Montana", "NE - Nebraska", "NV - Nevada", "NH - New Hampshire",
"NJ - New Jersey", "NM - New Mexico", "NY - New York", "NC - North Carolina",
"ND - North Dakota", "OH - Ohio", "OK - Oklahoma", "OR - Oregon", "PA - Pennsylvania",
"RI - Rhode Island", "SC - South Carolina", "SD - South Dakota", "TN - Tennessee",
"TX - Texas", "UT - Utah", "VT - Vermont", "VA - Virgina", "WA - Washington", "WV - West Virginia",
"WI - Wisconsin", "WY - Wyoming"]

@tudorschlanger

This comment has been minimized.

Copy link

@tudorschlanger tudorschlanger commented Apr 13, 2019

Thank you kindly!

@mattmecoli

This comment has been minimized.

Copy link

@mattmecoli mattmecoli commented May 8, 2019

Much appreciated!

@tlancon

This comment has been minimized.

Copy link

@tlancon tlancon commented May 15, 2019

Thanks, huge help! Here is a dictionary with abbreviations as well: https://gist.github.com/tlancon/9794920a0c3a9990279de704f936050c

@SHi-ON

This comment has been minimized.

Copy link

@SHi-ON SHi-ON commented May 21, 2019

Tnx, saved time!
Alphabetically sorted, as well:
https://gist.github.com/SHi-ON/ffbaf1d709aa5f49dbfa177a3203ad18

@Scry-Saurav

This comment has been minimized.

Copy link

@Scry-Saurav Scry-Saurav commented Jan 7, 2020

Thanks!

@Rshn8411

This comment has been minimized.

Copy link

@Rshn8411 Rshn8411 commented Mar 11, 2020

Fantastic! Greatly appreciate this.

@yashmahendra13

This comment has been minimized.

Copy link

@yashmahendra13 yashmahendra13 commented Apr 27, 2020

Thank you!

@snachman

This comment has been minimized.

Copy link

@snachman snachman commented Apr 28, 2020

Thank you!

@levimoore1992

This comment has been minimized.

Copy link

@levimoore1992 levimoore1992 commented Apr 30, 2020

thank you

@jwblaney

This comment has been minimized.

Copy link

@jwblaney jwblaney commented Jun 24, 2020

Thank you!

@mahdimq

This comment has been minimized.

Copy link

@mahdimq mahdimq commented Jul 4, 2020

Thank you so much for this! Saved some time for me.

@JohnDeJesus22

This comment has been minimized.

Copy link

@JohnDeJesus22 JohnDeJesus22 commented Jul 22, 2020

Thank you for making this convenient for us!

@agastidukare

This comment has been minimized.

Copy link

@agastidukare agastidukare commented Aug 25, 2020

God Bless You!

@dmcochener

This comment has been minimized.

Copy link

@dmcochener dmcochener commented Aug 26, 2020

Just a note that in the post @gingercyde made, Delaware, Illinois, and Virginia have typos in them. Also, if you need it as a list of tuples (like for Flask or Django forms) here ya go:
STATES_TUPLE = [("AL","Alabama"),("AK","Alaska"),("AZ","Arizona"),("AR","Arkansas"),("CA", "California"),("CO", "Colorado"),
("CT","Connecticut"),("DC","Washington DC"),("DE","Delaware"),("FL","Florida"),("GA","Georgia"),
("HI","Hawaii"),("ID","Idaho"),("IL","Illinois"),("IN","Indiana"),("IA","Iowa"),("KS","Kansas"),("KY","Kentucky"),
("LA","Louisiana"),("ME","Maine"),("MD","Maryland"),("MA","Massachusetts"),("MI","Michigan"),("MN","Minnesota"),
("MS","Mississippi"),("MO","Missouri"),("MT","Montana"),("NE","Nebraska"),("NV","Nevada"),("NH","New Hampshire"),
("NJ","New Jersey"),("NM","New Mexico"),("NY","New York"),("NC","North Carolina"),("ND","North Dakota"),("OH","Ohio"),
("OK","Oklahoma"),("OR","Oregon"),("PA","Pennsylvania"),("RI","Rhode Island"),("SC","South Carolina"),("SD","South Dakota"),
("TN","Tennessee"),("TX","Texas"),("UT","Utah"),("VT","Vermont"),("VA","Virginia"),("WA","Washington"),("WV","West Virginia"),
("WI","Wisconsin"),("WY","Wyoming")]

@nightduck

This comment has been minimized.

Copy link

@nightduck nightduck commented Sep 19, 2020

Saving thousands of developers 2 minutes each

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.