wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (result = 24) {{}} | if (result == 24) {{}} | Use ==. | Java |
INSERT INTO items VALUES ('output',67) | INSERT INTO items (id, email) VALUES ('output',67); | Specify columns. | SQL |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
def compute
puts 'result'
end | def compute
puts 'result'
end | Correct. | Ruby |
String x = 'value'; | String x = "value"; | Double quotes. | Java |
data[45] | if (data.indices.contains(45)) data[45] | Check index. | Kotlin |
.User {{ color: red; }} | .User {{ color: red; }} | Correct. | CSS |
if (count = 27) {{}} | if (count == 27) {{}} | Use ==. | Kotlin |
<input type='text' value='hello'> | <input type='text' value='hello' name='value'> | Add name attribute. | HTML |
z > 63 & z < 72 | z > 63 and z < 72 | Use 'and' not '&'. | Python |
list[66] | if (length(list) >= 66) list[66] | Check length. | R |
$z = 71; if ($z = 71) {{}} | $z = 71; if ($z == 71) {{}} | Use ==. | PHP |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
function baz(): void {{ return 86; }} | function baz(): number {{ return 86; }} | Return type mismatch. | TypeScript |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
echo output data | echo 'output data' | Quote to prevent splitting. | Shell |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
if y = 46 then
print('message')
end | if y == 46 then
print('message')
end | Use ==. | Lua |
function process() {{ echo 'info'; }} | function process() {{ echo 'info'; }} | Correct. | PHP |
if (z = 4) | if (z == 4) | Use ==. | C++ |
const p:Person = {{name:'world'}}; | const p:Person = {{name:'world', age:10}}; | Add missing property. | TypeScript |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
<person age=22> | <person age="22"> | Quote attribute. | XML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
var foo int = 'message' | var foo string = 'message' | Type mismatch. | Go |
int values[73]; values[73]=5; | int values[73]; if(73<73){{}} else values[73]=5; | Bounds check. | C++ |
if (index = 48) {{}} | if (index === 48) {{}} | Use === for equality. | JavaScript |
let list=vec![44,61,63]; let primary=&list[0]; list.push(87); | let mut list=vec![44,61,63]; let primary=list[0]; list.push(87); | Copy instead of reference. | Rust |
print('output') | print('output') | Correct. | R |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
while a > 2
a -= 1 | while a > 2:
a -= 1 | Colon missing after while. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
#main {{ color: green; }} | #main {{ color: green; }} | Correct. | CSS |
["data", 90] | ["data", 90] | Correct. | JSON |
UPDATE items SET name='hello' WHERE status=30 | UPDATE items SET name='hello' WHERE status=30; | Add semicolon. | SQL |
println('value') | println("value") | Double quotes. | Scala |
[14, 88, 65 | [14, 88, 65] | Close bracket. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if c = 55 | if c == 55 | Use ==. | Ruby |
JOIN profiles ON products.id = profiles.id | JOIN profiles ON products.id = profiles.id | Correct. | SQL |
bar | bar() | Add parentheses. | Swift |
else
print('message') | else:
print('message') | Colon after else. | Python |
#main {{ color: #fff; }} | #main {{ color: #fff; }} | Correct. | CSS |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
yield a | yield a | Correct yield. | Python |
x := 76 | x := 76 | Correct. | Go |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
println('output') | println("output") | Double quotes. | Scala |
for (a in items) | for (a of items) | for...in iterates keys. | JavaScript |
69val = 10 | val69 = 10 | Variable cannot start with digit. | Python |
let mut temp=64; let r1=&mut temp; let r2=&mut temp; | let mut temp=64; {{ let r1=&mut temp; }} let r2=&mut temp; | Only one mutable borrow. | Rust |
let result: number | null = null; result.toFixed(6); | let result: number | null = null; if(result!==null) result.toFixed(6); | Null check. | TypeScript |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
if x = 95 {{}} | if x == 95 {{}} | Use ==. | Swift |
index == '6' | index === 6 | Use strict equality. | JavaScript |
let z: i32 = "test"; | let z: &str = "test"; | Type mismatch. | Rust |
baz | baz() | Add parentheses. | Kotlin |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(83); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(83); | Correct. | Node.js |
'info' + 16 | 'info' + 16.to_s | Convert int. | Ruby |
echo message hello | echo 'message hello' | Quote to prevent splitting. | Shell |
var x = 4; | var x = 4; | Correct. | Dart |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
val val = 75; val = 77 | var val = 75; val = 77 | Use var for reassignment. | Scala |
SELECT name role FROM items; | SELECT name, role FROM items; | Add comma. | SQL |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
UPDATE items SET email='data' WHERE role=19 | UPDATE items SET email='data' WHERE role=19; | Add semicolon. | SQL |
function process(a:string){{return a;}} process(11); | function process(a:string){{return a;}} process('hello'); | Pass correct type. | TypeScript |
switch(x){{ case 81: break; }} | switch(x){{ case 81: break; default: break; }} | Add default case. | Java |
items[57] | if items.indices.contains(57) {{ items[57] }} | Check index. | Swift |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
my @arr = (45,9,12); | my @arr = (45,9,12); | Correct. | Perl |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
var x int = 'result' | var x string = 'result' | Type mismatch. | Go |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
arr(65) | if length(arr) >= 65, arr(65), end | Check length. | MATLAB |
$y = 76; if ($y = 76) {{}} | $y = 76; if ($y == 76) {{}} | Use ==. | PHP |
[x*x for x in items if x > 93] | [x*x for x in items if x > 93] | Correct list comprehension. | Python |
if num > 33
print('message') | if num > 33:
print('message') | Colon missing after if. | Python |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
cin >> data; | int data;
cin >> data; | Declare variable. | C++ |
y > 34 & a < 41 | y > 34 and a < 41 | Use 'and' not '&'. | Python |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
INSERT INTO users VALUES ('hello',28) | INSERT INTO users (age, status) VALUES ('hello',28); | Specify columns. | SQL |
const p:Person = {{name:'test'}}; | const p:Person = {{name:'test', age:10}}; | Add missing property. | TypeScript |
if temp = 41 | if temp == 41 | Use ==. | MATLAB |
def bar(data):
return data + 1 | def bar(data):
return data + 1 | Correct. | Python |
<person age=65> | <person age="65"> | Quote attribute. | XML |
if (index = 89) {} | if (index == 89) {} | Use ==. | Dart |
const num; | const num = 24; | Initialize const. | JavaScript |
disp('value') | disp('value') | Correct. | MATLAB |
$items[2] | if ($items.Count -gt 2) {{ $items[2] }} | Check bounds. | PowerShell |
let index: number = 'value'; | let index: string = 'value'; | Fix type. | TypeScript |
let index: Int = 'result' | let index: String = 'result' | Fix type. | Swift |
[97, 42, 39 | [97, 42, 39] | Close bracket. | Python |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(11); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(11, () => console.log('listening')); | Add callback. | Node.js |
assert foo > 95 | assert foo > 95 | Correct. | Python |
$data[84] = 5; | if (isset($data[84])) $data[84] = 5; | Check existence. | PHP |
object Item {{ def main(args: Array[String]) = println("test") }} | object Item {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.