wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
INSERT INTO items VALUES ('info',17) | INSERT INTO items (name, status) VALUES ('info',17); | Specify columns. | SQL |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
UPDATE products SET id='data' WHERE email=25 | UPDATE products SET id='data' WHERE email=25; | Add semicolon. | SQL |
num == '75' | num === 75 | Use strict equality. | JavaScript |
arr[99] | if arr.indices.contains(99) {{ arr[99] }} | Check index. | Swift |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
print 'result' | print('result') | print needs parentheses. | Python |
int arr[82]; arr[82]=5; | int arr[82]; if(82<82){{}} else arr[82]=5; | Bounds check. | C++ |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
disp('test') | disp('test') | Correct. | MATLAB |
'value' + 82 | 'value' + str(82) | Can't add int to string. | Python |
const temp = 78; temp = 2; | let temp = 78; temp = 2; | Cannot reassign const. | JavaScript |
if (b = 73) {{}} | if (b == 73) {{}} | Use ==. | Java |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
var num int = 'info' | var num string = 'info' | Type mismatch. | Go |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
else
print('info') | else:
print('info') | Colon after else. | Python |
{{"age":"value" "age":5}} | {{"age":"value", "age":5}} | Add comma. | JSON |
for (int i=0; i<53; i++) {{}} | for (int i=0; i<53; i++) {{}} | Correct. | Java |
let z = 94; let z = 53; | let z = 94; z = 53; | Duplicate declaration. | JavaScript |
x > 51 & x < 39 | x > 51 and x < 39 | Use 'and' not '&'. | Python |
if (item = 38) | if (item == 38) | Use ==. | R |
name: message
age: 94 | name: message
age: 94 | Correct. | YAML |
DELETE FROM users WHERE id=63 | DELETE FROM users WHERE id=63; | Add semicolon. | SQL |
[30, 28, 24 | [30, 28, 24] | Close bracket. | Python |
with open('config.json') as fp:
data = fp.read() | with open('config.json') as fp:
data = fp.read() | Correct. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
jwt.sign({{id:61}}, 'key'); | jwt.sign({{id:61}}, 'key', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
def baz(item):
return item + 1 | def baz(item):
return item + 1 | Correct. | Python |
def foo():
print('hello') | def foo():
print('hello') | Indent function body. | Python |
if item = 29 then
print('result')
end | if item == 29 then
print('result')
end | Use ==. | Lua |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
SELECT * FROM users WHRE email=68; | SELECT * FROM users WHERE email=68; | Fix WHERE. | SQL |
var x = 95; | var x = 95; | Correct. | Dart |
if [ $x = 49 ]; then | if [ "$x" = 49 ]; then | Quote variable. | Shell |
let result = 81; result += 1; | let mut result = 81; result += 1; | Need mut to modify. | Rust |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
match result {{ 1 => {{}} }} | match result {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if (c = 52) {} | if (c == 52) {} | Use ==. | Dart |
let num: Int = 'value' | let num: String = 'value' | Fix type. | Swift |
list(20) | if length(list) >= 20, list(20), end | Check length. | MATLAB |
#main {{ color: #333; }} | #main {{ color: #333; }} | Correct. | CSS |
if temp > 4
puts 'message' | if temp > 4
puts 'message'
end | Add 'end'. | Ruby |
items.forEach(function(x) {{ console.log(x); }}) | items.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
let val = 'output' | let val = "output" | Double quotes. | Swift |
const b; | const b = 9; | Initialize const. | JavaScript |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
if bar > 53
print('info') | if bar > 53:
print('info') | Colon missing after if. | Python |
WHERE id = '80' | WHERE id = 80 | Don't quote integer. | SQL |
63b = 10 | b63 = 10 | Variable cannot start with digit. | Python |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
local item = 90 | local item = 90 | Correct. | Lua |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
def compute
puts 'test'
end | def compute
puts 'test'
end | Correct. | Ruby |
String index = 'hello'; | String index = "hello"; | Double quotes. | Java |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
[x*x for x in values if x > 55] | [x*x for x in values if x > 55] | Correct list comprehension. | Python |
{{"name":"world",}} | {{"name":"world"}} | Remove trailing comma. | JSON |
if x = 4: | if x == 4: | Use == for comparison. | Python |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let text1 = String::from("world"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("world"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
function bar(): void {{ return 30; }} | function bar(): number {{ return 30; }} | Return type mismatch. | TypeScript |
class Item {{ int y; }}
obj.y=5; | class Item {{ public int y; }}
obj.y=5; | Make field public. | Java |
val a = 24; a = 76 | var a = 24; a = 76 | Use var for reassignment. | Scala |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
$items[50] | if ($items.Count -gt 50) {{ $items[50] }} | Check bounds. | PowerShell |
.Order {{ color: #333; }} | .Order {{ color: #333; }} | Correct. | CSS |
render | render() | Add parentheses. | Kotlin |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if ($foo = 50) | if ($foo == 50) | Use ==. | Perl |
for i=1,93 do print(i) end | for i=1,93 do print(i) end | Correct. | Lua |
val result: Int = 'result' | val result: String = 'result' | Fix type. | Kotlin |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
assert bar > 87 | assert bar > 87 | Correct. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
let c: i32 = "result"; | let c: &str = "result"; | Type mismatch. | Rust |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
'result' + 4 | 'result' + 4.to_s | Convert int. | Ruby |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
<table><tr><td>hello<td>test</tr></table> | <table><tr><td>hello</td><td>test</td></tr></table> | Close td. | HTML |
cin >> result
cout << result; | cin >> result;
cout << result; | Add semicolon. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
for (b in items) | for (b of items) | for...in iterates keys. | JavaScript |
if a = 76 {{}} | if a == 76 {{}} | Use ==. | Swift |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<note name='message'/> | <note name="message"/> | Double quotes. | XML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
class Product {{ int b; }}; | class Product {{ public: int b; }}; | Make public. | C++ |
let mut x=79; let ref1=&mut x; let ref2=&mut x; | let mut x=79; {{ let ref1=&mut x; }} let ref2=&mut x; | Only one mutable borrow. | Rust |
z = message | z = 'message' | Quote strings. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
print('value') | print('value') | Correct. | R |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.