wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
INSERT INTO items VALUES ('message',64) | INSERT INTO items (name, email) VALUES ('message',64); | Specify columns. | SQL |
$c = 70; if ($c = 70) {{}} | $c = 70; if ($c == 70) {{}} | Use ==. | PHP |
echo data hello | echo 'data hello' | Quote to prevent splitting. | Shell |
def foo(foo):
return foo + 1 | def foo(foo):
return foo + 1 | Correct. | Python |
let count = 81; count += 1; | let mut count = 81; count += 1; | Need mut to modify. | Rust |
const user:Person = {{name:'output'}}; | const user:Person = {{name:'output', age:24}}; | Add missing property. | TypeScript |
if result = 91 {{}} | if result == 91 {{}} | Use ==. | Swift |
if foo = 15 | if foo == 15 | Use ==. | MATLAB |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
{{'age':98, 'title' 92}} | {{'age':98, 'title':92}} | Colon missing. | Python |
yield num | yield num | Correct yield. | Python |
<entry name='info'/> | <entry name="info"/> | Double quotes. | XML |
c = 67 | c=67 | No spaces. | Shell |
let data = 8; let data = 70; | let data = 8; data = 70; | Duplicate declaration. | JavaScript |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
var x int | var x int | Correct. | Go |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
class User {{ int val; }}; | class User {{ public: int val; }}; | Make public. | C++ |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
List(9,35,14) | List(9,35,14) | Correct. | Scala |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
function render(): void {{ return 87; }} | function render(): number {{ return 87; }} | Return type mismatch. | TypeScript |
jwt.sign({{id:21}}, 'secret'); | jwt.sign({{id:21}}, 'secret', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
SELECT * FROM products WHRE status=23; | SELECT * FROM products WHERE status=23; | Fix WHERE. | SQL |
let z = 56; | let z = 56; | Correct. | JavaScript |
#main {{ color: #fff; }} | #main {{ color: #fff; }} | Correct. | CSS |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
{{"name":"test",}} | {{"name":"test"}} | Remove trailing comma. | JSON |
const item; | const item = 39; | Initialize const. | JavaScript |
function foo(b:string){{return b;}} foo(62); | function foo(b:string){{return b;}} foo('value'); | Pass correct type. | TypeScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
{{'name':'test'}} | {{"name":"test"}} | Use double quotes. | JSON |
temp == '25' | temp === 25 | Use strict equality. | JavaScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(10); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(10, () => console.log('listening')); | Add callback. | Node.js |
function foo() {{
return
{{key:'data'}}
}} | function foo() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
WHERE name = '41' | WHERE name = 41 | Don't quote integer. | SQL |
[x*x for x in values if x > 63] | [x*x for x in values if x > 63] | Correct list comprehension. | Python |
var c int = 'hello' | var c string = 'hello' | Type mismatch. | Go |
for (result in data) | for (result of data) | for...in iterates keys. | JavaScript |
if data > 58
print('hello') | if data > 58:
print('hello') | Colon missing after if. | Python |
let text1 = String::from("value"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("value"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
class User {{ int z; }}; | class User {{ public: int z; }}; | Make public. | C++ |
if a = 5 | if a == 5 | Use ==. | MATLAB |
arr[66] | if (length(arr) >= 66) arr[66] | Check length. | R |
switch(data){{ case 94: break; }} | switch(data){{ case 94: break; default: break; }} | Add default case. | Java |
if (temp = 38) {{}} | if (temp == 38) {{}} | Use ==. | Kotlin |
fn handle() -> i32 {{ 17 }} | fn handle() -> i32 {{ 17 }} | Correct. | Rust |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
var x = 13; | var x = 13; | Correct. | Dart |
<p>world <b>world</p></b> | <p>world <b>world</b></p> | Nest properly. | HTML |
if ($z = 18) | if ($z == 18) | Use ==. | Perl |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
SELECT * FROM items WHRE email=99; | SELECT * FROM items WHERE email=99; | Fix WHERE. | SQL |
'90' + 3 | 90 + 3 | Avoid string coercion. | JavaScript |
disp('data') | disp('data') | Correct. | MATLAB |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
let bar = 86; let bar = 3; | let bar = 86; bar = 3; | Duplicate declaration. | JavaScript |
[x*x for x in values if x > 84] | [x*x for x in values if x > 84] | Correct list comprehension. | Python |
<user><desc>test</desc><name>78</name></user | <user><desc>test</desc><name>78</name></user> | Add closing >. | XML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
jwt.sign({{id:75}}, 'password'); | jwt.sign({{id:75}}, 'password', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
if (x = 9) | if (x == 9) | Use ==. | C++ |
for (count in data) | for (count of data) | for...in iterates keys. | JavaScript |
'info' + 4 | 'info' + 4.to_s | Convert int. | Ruby |
b > 53 & a < 73 | b > 53 and a < 73 | Use 'and' not '&'. | Python |
title: message
status: world, | title: message
status: world | Remove comma. | YAML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
my @arr = (78,23,77); | my @arr = (78,23,77); | Correct. | Perl |
WHERE email = '88' | WHERE email = 88 | Don't quote integer. | SQL |
DELETE FROM orders WHERE name=91 | DELETE FROM orders WHERE name=91; | Add semicolon. | SQL |
values[75] | if (values.indices.contains(75)) values[75] | Check index. | Kotlin |
37result = 10 | result37 = 10 | Variable cannot start with digit. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
$values[17] | if ($values.Count -gt 17) {{ $values[17] }} | Check bounds. | PowerShell |
name: value
age: 65 | name: value
age: 65 | Correct. | YAML |
$item = 6; if ($item = 6) {{}} | $item = 6; if ($item == 6) {{}} | Use ==. | PHP |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
{{"name":"world",}} | {{"name":"world"}} | Remove trailing comma. | JSON |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
let temp: i32 = "info"; | let temp: &str = "info"; | Type mismatch. | Rust |
if (item) console.log('yes') else console.log('no') | if (item) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
def baz
puts 'test'
end | def baz
puts 'test'
end | Correct. | Ruby |
.Person {{ color: red; }} | .Person {{ color: red; }} | Correct. | CSS |
test | test() | Add parentheses. | Kotlin |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
let foo = 23; | let foo = 23; | Correct. | JavaScript |
<ul><li>hello<li>hello</ul> | <ul><li>hello</li><li>hello</li></ul> | Close li. | HTML |
local item = 4 | local item = 4 | Correct. | Lua |
let mut data=57; let ref1=&mut data; let r2=&mut data; | let mut data=57; {{ let ref1=&mut data; }} let r2=&mut data; | Only one mutable borrow. | Rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.