Question: I have googled on how to write a fixed length loop in Python but haven't found anything, so I ask here:

```
    for i in range(0, 25):
        index = int(random.uniform(0, len(characters)))
        code += characters[index]
    return code

```

As you see I don't need `i`. How can I rewrite this to be a fixed length loop where I don't have to define `i`?

Answer: 
Since you're tagging Laravel I suggest to you using the Query Builder like :

```
DB::table('dates')
    ->join('users', 'dates.user_id', '=', 'users.id')
    ->select(db::raw('users.name, user_id, max(date)'))
    ->groupBy('user_id','name')
    ->get();

```

**OUTPUT:**

```
Illuminate\Support\Collection {#2957
     all: [
       {#2944
         +"name": "name 1",
         +"user_id": 1,
         +"max": "2018-08-15",
       },
       {#2941
         +"name": "name 2",
         +"user_id": 2,
         +"max": "2018-08-14",
       },
     ],
   }

```
SELECT u.id,MAX(d.date),u.name FROM DATE d JOIN user u ON d.user\_id = u.id GROUP BY d.user\_id