'Dictionary' Question - UiPath Academy Related Practice & Solution

Hi All,

I have a pretty specific question related to dictionary in the ss.
The question I understand. As for the solution I get logic of the solution more or less but the “technicalities” of it I struggle quite a bit. (ss1: question, ss2: solution).

My issues:

  • I ran the the solutions workflow and it did give the desired output
  • However I’m having hard time understanding how the IF Condition is MET (under point 2). I don’t get it since ‘WinnerCounts’ does not contain any Key nor Value i.e. an empty dictionary, how could its .ContainKey match to anything in ‘TourDeFranceWinners.Values’
  • My understanding is that only the ELSE path (under point 2) would take place

I’m not sure if my question is making sense. But yeah hopefully someone can enlighten me

ss1 - question:

ss2 - solution from UiPath academy:

It’s a loop. On the first iteration of the loop, there’s nothing in the WinnerCounts dictionary so it goes to the Else which adds the person’s name as a key with the count as 1. On the next iteration of the loop if it’s the same person again, now the key for that name does exist in WinnerCounts so it goes to the Then and increments their count by 1.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.