[Tutor] (no subject)

David Rock david at graniteweb.com
Tue Feb 16 11:57:38 EST 2021


* Alan Gauld via Tutor <tutor at python.org> [2021-02-16 16:39]:
> On 16/02/2021 10:43, ੧ wrote:
> >  I have started learning Python recently.
> > Please help me with this.
> > 
> > Create a dictionary where all the keys are strings, and all the values are
> > integers.
> > For example: {'Monday':19,'Tuesday':20}
> > Write the dictionary on a single line, don't assign a variable name to the
> > dictionary.
> 
> What exactly do you need help with?
> You seem to have successfully solved the problem in your request.

To elaborate:
Are you expected to take a set of values and build the dictionary?
Are you expected to just write a dictionary (which you've already done, as Alan pointed out)?

With the statement having an already-correct example, the shortest path is to
replicate it with different values.  If we look at the example:

{'Monday':19,'Tuesday':20}

this is made up of {'string1': number1, 'string2': number2}

Strings in this context are characters inside quotes; 'string1' ,'string2', 'Monday', 'Tuesday', etc
integers are just real, whole numbers with no quotes: 19, 20, 34, -1, etc

So it sounds like you just need to write any dictionary that follows the above format.

-- 
David Rock	
david at graniteweb.com


More information about the Tutor mailing list