**Background**

I am working on some REST JSON calls via python to get a list of users. Unfortunately, the server can only return a maximum number of 50 users at a time.
e.g.

call "[0:49]" returns the first 50 users

call "[51:99]" returns the next batch of 50 users

The server does return the total number of users therefore, i am able to write some logic to get all users with multiple rest calls.

**Problem**

I have written a very messy function that prints the data in a dictionary format:

```
    def get_all_possible_items(max_no_users):
        dict={}
        base=0
        values=max_no_users//50
        if max_no_users>49:
            dict[base]=base+49
            base+=49
        else:
            base-=1
        for i in range(values-1):
            base+=1
            dict[base]=base+49
            base+=49
        dict[base+1]=max_no_users

        print dict

    get_all_possible_items(350)

```

The output looks like:

If max\_no\_users is 350:

> 
> {0: 49, 100: 149, 200: 249, 300: 349, 50: 99, 150: 199, 250: 299, 350: 350}
> 
> 
> 

if max\_no\_users is 351:

> 
> {0: 49, 100: 149, 200: 249, 300: 349, 50: 99, 150: 199, 250: 299, 350: 351}
> 
> 
> 

Is there a better way of writing this (there must be!)?