title: List every Cognito user
body: <p>I want to list for every user cognito the list of groups he belong make all information in a dictionary and convert it to a json format but I don't now where is the problem? </p>
  
  <pre><code>import json
  import boto3
  
  def lambda_handler(event, context):
  
      client = boto3.client('cognito-idp')
      UserPool_Id = "eu-west-1_NxL8iQjim"
      List_Group_Name = list()
      dicti = {}
  
      # On recupère la liste de tout les utilisateurs
      try:
          response = client.list_users(
              UserPoolId=UserPool_Id,
          )
      except:
          print ("Error message")
  
      response = client.list_users(
              UserPoolId=UserPool_Id
          )
  
      i = len(response["Users"])
  
  
      while (i&gt;0):
          #pour chaque utilisateur
          for user in response["Users"]:
  
              dicti["Users"][i]["UserName"]=user["Username"]
  
              response2 = client.admin_list_groups_for_user(
                  Username=user["Username"],
                  UserPoolId=UserPool_Id
              )
  
              List_Group_Name=list()
              for group in  response2["Groups"]:
                  List_Group_Name.append(group["GroupName"])
  
              dicti["Users"][i]["UserName"]=List_Group_Name
          i=i-1
  
      return(dicti)
  </code></pre>