avatar Bite 228. Create a Gravatar URL

In this Bite you will generate a Gravatar URL, e.g. https://www.gravatar.com/avatar/5b13356d467af88631503c27a3d0e0cf?s=200&r=g&d=robohash.

In this URL 5b13356d467af88631503c27a3d0e0cf is a hash of a lowercase and stripped email address.

Code create_gravatar_url hashing the passed in email arg. You can see a PHP example and you want to use hashlib + its md5 / hexdigest methods ...

Here is how the function works in the REPL. Note that spaces and case sensitivity won't matter: they produce the same hash and thus gravatar:

>>> from gravatar import create_gravatar_url
>>> create_gravatar_url("[email protected]")
'https://www.gravatar.com/avatar/5b13356d467af88631503c27a3d0e0cf?s=200&r=g&d=robohash'
>>> create_gravatar_url("[email protected]", 300)
'https://www.gravatar.com/avatar/5b13356d467af88631503c27a3d0e0cf?s=300&r=g&d=robohash'
>>> create_gravatar_url("[email protected] ", 300)
'https://www.gravatar.com/avatar/5b13356d467af88631503c27a3d0e0cf?s=300&r=g&d=robohash'
>>> create_gravatar_url("[email protected] ", 300)
'https://www.gravatar.com/avatar/5b13356d467af88631503c27a3d0e0cf?s=300&r=g&d=robohash'

(More information about the other parameters here)

Have fun and keep calm and code in Python!

Login and get coding
go back Intermediate level
Bitecoin 3X

94 out of 94 users completed this Bite.
Will you be the 95th person to crack this Bite?
Resolution time: ~30 min. (avg. submissions of 5-240 min.)
Our community rates this Bite 2.8 on a 1-10 difficulty scale.
» You can do it! 😌

Focus on this Bite hiding sidebars, turn on Focus Mode.

Ask for Help