I'm trying to take a list that can be size 1 or greater and convert it to a string with formatting `"val1, val2, val3 and val4"` where you can have different list lengths and the last value will be formatted with an and before it instead of a comma.

My current code:

```
inputlist = ["val1", "val2", "val3"]
outputstr = ""
            for i in range(len(inputlist)-1):
                if i == len(inputlist)-1:
                    outputstr = outputstr + inputlist[i]
                elif i == len(inputlist)-2:
                    outputstr = f"{outputstr + inputlist[i]} and "
                else:
                    outputstr = f"{outputstr + inputlist[i]}, "
            print(f"Formatted list is: {outputstr}")

```

Expected result:

```
Formatted list is: val1, val2 and val3

```