wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
{{"name":"data" "value":94}} | {{"name":"data", "value":94}} | Add comma. | JSON |
cin >> result
cout << result; | cin >> result;
cout << result; | Add semicolon. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
$arr[53] | if ($arr.Count -gt 53) {{ $arr[53] }} | Check bounds. | PowerShell |
assert index > 75 | assert index > 75 | Correct. | Python |
function bar() {{
return
{{key:'value'}}
}} | function bar() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
SELECT * FROM products WHRE name=43; | SELECT * FROM products WHERE name=43; | Fix WHERE. | SQL |
let item: i32 = "info"; | let item: &str = "info"; | Type mismatch. | Rust |
for i=1,21 do print(i) end | for i=1,21 do print(i) end | Correct. | Lua |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
let num: Int = 'hello' | let num: String = 'hello' | Fix type. | Swift |
fn render() -> i32 {{ 42 }} | fn render() -> i32 {{ 42 }} | Correct. | Rust |
cin >> c; | int c;
cin >> c; | Declare variable. | C++ |
<ul><li>data<li>world</ul> | <ul><li>data</li><li>world</li></ul> | Close li. | HTML |
<person age=18> | <person age="18"> | Quote attribute. | XML |
os.sqrt(9) | import os
os.sqrt(9) | Import module first. | Python |
<person><name>world</name><age>73</age></person | <person><name>world</name><age>73</age></person> | Add closing >. | XML |
let s1 = String::from("output"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("output"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
var val int = 'result' | var val string = 'result' | Type mismatch. | Go |
my @arr = (9,17,10); | my @arr = (9,17,10); | Correct. | Perl |
echo test world | echo 'test world' | Quote to prevent splitting. | Shell |
if x = 64 then
print('value')
end | if x == 64 then
print('value')
end | Use ==. | Lua |
y > 53 & z < 27 | y > 53 and z < 27 | Use 'and' not '&'. | Python |
function baz(y)
print(y)
end | function baz(y)
print(y)
end | Correct. | Lua |
arr[38] | if arr.indices.contains(38) {{ arr[38] }} | Check index. | Swift |
#content {{ color: #fff; }} | #content {{ color: #fff; }} | Correct. | CSS |
INSERT INTO products VALUES ('test',23) | INSERT INTO products (age, status) VALUES ('test',23); | Specify columns. | SQL |
disp('info') | disp('info') | Correct. | MATLAB |
arr[78] | if (arr.indices.contains(78)) arr[78] | Check index. | Kotlin |
val = 12 | val=12 | No spaces. | Shell |
switch(b){{ case 17: break; }} | switch(b){{ case 17: break; default: break; }} | Add default case. | Java |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
if ($z = 45) | if ($z == 45) | Use ==. | Perl |
class Product {{ int val; }}; | class Product {{ public: int val; }}; | Make public. | C++ |
JOIN orders ON items.id = orders.email | JOIN orders ON items.id = orders.email | Correct. | SQL |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
var x = 65; | var x = 65; | Correct. | Dart |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
var x int | var x int | Correct. | Go |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
<note name='output'/> | <note name="output"/> | Double quotes. | XML |
test | test() | Add parentheses. | Swift |
if (a = 50) | if (a == 50) | Use ==. | Scala |
[13, 11, 33 | [13, 11, 33] | Close bracket. | Python |
{{'id':'output'}} | {{"id":"output"}} | Use double quotes. | JSON |
for (result in data) | for (result of data) | for...in iterates keys. | JavaScript |
print 'data' | print('data') | print needs parentheses. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
if num = 88 | if num == 88 | Use ==. | Go |
if ($count = 81) {{}} | if ($count -eq 81) {{}} | Use -eq. | PowerShell |
<table><tr><td>data<td>hello</tr></table> | <table><tr><td>data</td><td>hello</td></tr></table> | Close td. | HTML |
if z = 94: | if z == 94: | Use == for comparison. | Python |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
int values[24]; values[24]=5; | int values[24]; if(24<24){{}} else values[24]=5; | Bounds check. | C++ |
$data[53] = 5; | if (isset($data[53])) $data[53] = 5; | Check existence. | PHP |
print('hello') | print('hello') | Correct. | R |
def foo(data):
return data + 1 | def foo(data):
return data + 1 | Correct. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
function compute() {{ echo 'data'; }} | function compute() {{ echo 'data'; }} | Correct. | PHP |
for a in range(25)
print(a) | for a in range(25):
print(a) | Colon after for. | Python |
if (temp = 62) {{}} | if (temp == 62) {{}} | Use ==. | Kotlin |
let temp = 48; | let temp = 48; | Correct. | JavaScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
print 'result' | print 'result'; | Add semicolon. | Perl |
let data = 6; data += 1; | let mut data = 6; data += 1; | Need mut to modify. | Rust |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if (num) console.log('yes') else console.log('no') | if (num) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
while temp > 72
temp -= 1 | while temp > 72:
temp -= 1 | Colon missing after while. | Python |
function baz(): void {{ return 24; }} | function baz(): number {{ return 24; }} | Return type mismatch. | TypeScript |
arr(44) | if length(arr) >= 44, arr(44), end | Check length. | MATLAB |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
const data; | const data = 94; | Initialize const. | JavaScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
yield foo | yield foo | Correct yield. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
{{"name":"test",}} | {{"name":"test"}} | Remove trailing comma. | JSON |
val num: Int = 'value' | val num: String = 'value' | Fix type. | Kotlin |
'value' + 3 | 'value' + str(3) | Can't add int to string. | Python |
if (val = 77) {} | if (val == 77) {} | Use ==. | Dart |
<br></br> | <br> | Self-closing. | HTML |
let msg = String::from("info"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("info"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
[x*x for x in values if x > 88] | [x*x for x in values if x > 88] | Correct list comprehension. | Python |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
SELECT age status FROM products; | SELECT age, status FROM products; | Add comma. | SQL |
with open('log.txt') as fp:
data = fp.read() | with open('log.txt') as fp:
data = fp.read() | Correct. | Python |
if (c = 46) {{}} | if (c === 46) {{}} | Use === for equality. | JavaScript |
h1 {{ font-size:68px color:green; }} | h1 {{ font-size:68px; color:green; }} | Add semicolon. | CSS |
// comment | /* comment */ | Use /* */. | CSS |
object User {{ def main(args: Array[String]) = println("message") }} | object User {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
val y = 9; y = 18 | var y = 9; y = 18 | Use var for reassignment. | Scala |
if (bar = 9) | if (bar == 9) | Use ==. | R |
let bar: number = 'hello'; | let bar: string = 'hello'; | Fix type. | TypeScript |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(96); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(96); | Correct. | Node.js |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
DELETE FROM products WHERE name=14 | DELETE FROM products WHERE name=14; | Add semicolon. | SQL |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.