Paste the error. Get the fix.
Why does last([]) crash with IndexError: list index out of range?
last() reads xs[len(xs)], one past the end 1. Return xs[-1] and guard the empty list:
def last(xs):
if not xs:
raise ValueError("last() of an empty list")
return xs[-1]
Built for the bug you can't find.
Reads your code and your stack traces
Attach files or paste a trace. MGS AI finds the cause, explains it and writes the fix.
def last(xs):
- return xs[len(xs)]
+ if not xs:
+ raise ValueError("last() of an empty list")
+ return xs[-1]
Searches the web, shows its sources
Answers about libraries and APIs come with links you can check.
- 1
Built-in Types: common sequence operationsdocs.python.org
- 2
IndexError: list index out of rangestackoverflow.com
- 3
An Informal Introduction to Python: listsdocs.python.org
Thinks before it answers
Open the thinking to see how it got there, or leave it folded away.
Thought for 14 s
Runs code to check itself
From xHigh up, it can test an answer in a Python sandbox.
$ pytest test_last.py
3 passed in 0.04sMakes images, too
Icons, diagrams and illustrations, right in the chat. Every image is saved to your library and marked as AI-made.

One model. Six levels of effort.
MGS AI 1 can answer instantly or think for minutes, and it can search the web at every level. Higher effort thinks longer and counts more toward your limit. Free includes Low and Medium; every paid plan includes all six.
Low
Answers right away and can search the web.
Included in Free
Medium
Thinks briefly, searches and reads pages.
Included in Free
High
Thinks longer, searches and reads pages.
From Basic
xHigh
Thinks deeply and runs code to check its work.
From Basic
Max
Works out several drafts, then one combined answer.
From Basic
Ultra
Four independent attempts, checked and merged.
From Basic
Your code stays yours.
MGS AI is made by Max's Global Solutions in Latvia. We store as little as we can and you control all of it.
Read the privacy policyEncrypted storage in the EU
Uploads and images live in an encrypted bucket in Stockholm. Links to them expire after 5 minutes.
No message logs
The AI engine records request metadata such as token counts, never your messages or files.
Export or delete anytime
Download all your data as JSON, or delete your account and its files in settings.
Essential cookies only
No ads, no tracking pixels and no analytics cookies.
Start free. Upgrade when you need more.
Free
€0/mo
Low and Medium effort15 units per 5 h
Basic
€5/mo
All 6 efforts60 units per 5 h
Plus
€10/mo
All 6 efforts150 units per 5 h
Pro
€20/mo
All 6 efforts400 units per 5 h
Pro+
€50/mo
All 6 efforts1,200 units per 5 h
MAX
€100/mo
All 6 efforts3,000 units per 5 h
Monthly, in euros, through PayPal. Cancel anytime.
See pricing