Skip to content

Instantly share code, notes, and snippets.

@bryanlimy
Created February 21, 2017 20:20
Show Gist options
  • Save bryanlimy/c4cb9cc412d86f9d24223296ce1283df to your computer and use it in GitHub Desktop.
Save bryanlimy/c4cb9cc412d86f9d24223296ce1283df to your computer and use it in GitHub Desktop.
Instagram Hashtags Counter
def main():
# get the hashtags in string form
string = input("Please paste your hashtags: ")
# remove spaces and convert string to list of hashtags
hashtags = string.split()
# convert list to lowercase
hashtags = [hashtag.lower() for hashtag in hashtags]
# count and print number of hashtags
count = len(hashtags)
print("\nNumber of hashtags: " + str(count))
# warn if more than 30 hashtags are found
if (count > 30):
print("Warning - Instagram allows maximum of 30 hashtags per comment")
# check duplicate
duplicate = len(hashtags) - len(set(hashtags))
if (duplicate > 0):
print("Number of duplicated hashtag(s): " + str(duplicate))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment