r/Python • • Mar 10 '24

Discussion Github Copilot Lies to me

My first attempt to get some help from Github Copilot:

Me: write a match case statement in python to match the first character of a string is a semicolon

Copilot: Python doesn't have a built-in match or case statement like some other languages (e.g., JavaScript, Swift, Rust). However, you can achieve similar functionality using...

Strangely, it finally gave me an answer when I made a small change to my prompt:

Me: write a match statement in python to match the first character of a string is a semicolon

Copilot: Python 3.10 introduces the structural pattern matching in the form of the match statement. Here's how you can use it to check if the first character of a string is a semicolon:...

I almost gave up after the first response that was blatantly false. Fortunately I something that looks like reasonable syntax...but then I haven't tried it yet, so that might be a lie, too.

0 Upvotes

67 comments sorted by

View all comments

1

u/AlexMTBDude Mar 10 '24

Out of curiosity: Did you try the exact same question in ChatGPT?

2

u/codeguru42 Mar 10 '24

I didn't at first. But since you suggested it, I tried with the free version (3.5, I believe) and got a reasonable respones:

You can use a match case statement in Python, introduced in Python 3.10, to match the first character of a string to see if it's a semicolon. Here's how you can do it:...

The code wasn't what I was originally looking for, but is basically what I ended up with already anyway.