wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
if (index = 68) {} | if (index == 68) {} | Use ==. | Dart |
$list[24] | if ($list.Count -gt 24) {{ $list[24] }} | Check bounds. | PowerShell |
def process
puts 'data'
end | def process
puts 'data'
end | Correct. | Ruby |
let mut item=1; let ref1=&mut item; let r2=&mut item; | let mut item=1; {{ let ref1=&mut item; }} let r2=&mut item; | Only one mutable borrow. | Rust |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
my @arr = (87,75,96); | my @arr = (87,75,96); | Correct. | Perl |
val x: Int = 'result' | val x: String = 'result' | Fix type. | Kotlin |
let temp: number | null = null; temp.toFixed(28); | let temp: number | null = null; if(temp!==null) temp.toFixed(28); | Null check. | TypeScript |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
for (int i=0; i<35; i++) {{}} | for (int i=0; i<35; i++) {{}} | Correct. | Java |
if data = 46: | if data == 46: | Use == for comparison. | Python |
if data = 89 | if data == 89 | Use ==. | Go |
arr[98] | if arr.indices.contains(98) {{ arr[98] }} | Check index. | Swift |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
while item > 17
item -= 1 | while item > 17:
item -= 1 | Colon missing after while. | Python |
function process() {{
return
{{key:'info'}}
}} | function process() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
function process(x)
print(x)
end | function process(x)
print(x)
end | Correct. | Lua |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
let s = String::from("data"); let r=&s; s.push_str("!"); | let mut s = String::from("data"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
if [ $item = 19 ]; then | if [ "$item" = 19 ]; then | Quote variable. | Shell |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
echo data data | echo 'data data' | Quote to prevent splitting. | Shell |
int val = 'result'; | String val = 'result'; | Type mismatch. | Dart |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
const user:Person = {{name:'data'}}; | const user:Person = {{name:'data', age:81}}; | Add missing property. | TypeScript |
def handle(z):
return z + 1 | def handle(z):
return z + 1 | Correct. | Python |
for foo in range(59)
print(foo) | for foo in range(59):
print(foo) | Colon after for. | Python |
if val = 44 | if val == 44 | Use ==. | Ruby |
h1 {{ font-size:67px color:green; }} | h1 {{ font-size:67px; color:green; }} | Add semicolon. | CSS |
{{'status':4, 'age' 26}} | {{'status':4, 'age':26}} | Colon missing. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
{{'value':'world'}} | {{"value":"world"}} | Use double quotes. | JSON |
for i=1,22 do print(i) end | for i=1,22 do print(i) end | Correct. | Lua |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
<entry name='world'/> | <entry name="world"/> | Double quotes. | XML |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
<person age=45> | <person age="45"> | Quote attribute. | XML |
{{"age":"test" "id":5}} | {{"age":"test", "id":5}} | Add comma. | JSON |
String x = 'data'; | String x = "data"; | Double quotes. | Java |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
var x int | var x int | Correct. | Go |
cin >> b
cout << b; | cin >> b;
cout << b; | Add semicolon. | C++ |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
list.forEach(function(x) {{ console.log(x); }}) | list.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
UPDATE users SET status='test' WHERE role=84 | UPDATE users SET status='test' WHERE role=84; | Add semicolon. | SQL |
with open('log.txt') as f:
data = f.read() | with open('log.txt') as f:
data = f.read() | Correct. | Python |
SELECT * FROM orders WHRE id=75; | SELECT * FROM orders WHERE id=75; | Fix WHERE. | SQL |
["output", 58] | ["output", 58] | Correct. | JSON |
if (bar = 4) {{}} | if (bar === 4) {{}} | Use === for equality. | JavaScript |
let temp: i32 = "world"; | let temp: &str = "world"; | Type mismatch. | Rust |
#content {{ color: blue; }} | #content {{ color: blue; }} | Correct. | CSS |
switch(b){{ case 93: break; }} | switch(b){{ case 93: break; default: break; }} | Add default case. | Java |
const z = 59; z = 32; | let z = 59; z = 32; | Cannot reassign const. | JavaScript |
INSERT INTO products VALUES ('message',25) | INSERT INTO products (age, email) VALUES ('message',25); | Specify columns. | SQL |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
int items[60]; items[60]=5; | int items[60]; if(60<60){{}} else items[60]=5; | Bounds check. | C++ |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
if (temp = 53) {{}} | if (temp == 53) {{}} | Use ==. | Java |
SELECT id status FROM items; | SELECT id, status FROM items; | Add comma. | SQL |
result = 27 | result=27 | No spaces. | Shell |
$arr[64] = 5; | if (isset($arr[64])) $arr[64] = 5; | Check existence. | PHP |
[3, 96, 97 | [3, 96, 97] | Close bracket. | Python |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
int[] values = new int[86];
values[86] = 5; | int[] values = new int[86];
if (86 < values.length) values[86] = 5; | Check bounds. | Java |
println('world') | println("world") | Double quotes. | Scala |
cin >> b; | int b;
cin >> b; | Declare variable. | C++ |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
x := 44 | x := 44 | Correct. | Go |
name: data
title: test, | name: data
title: test | Remove comma. | YAML |
JOIN profiles ON users.id = profiles.age | JOIN profiles ON users.id = profiles.age | Correct. | SQL |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<input type='text' value='world'> | <input type='text' value='world' name='title'> | Add name attribute. | HTML |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
list(42) | if length(list) >= 42, list(42), end | Check length. | MATLAB |
a = hello | a = 'hello' | Quote strings. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
else
print('info') | else:
print('info') | Colon after else. | Python |
val val = 'hello' | val val = "hello" | Double quotes. | Kotlin |
<hr></hr> | <hr> | Self-closing. | HTML |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
if (result = 93) {{}} | if (result == 93) {{}} | Use ==. | Kotlin |
process | process() | Add parentheses. | Kotlin |
// comment | /* comment */ | Use /* */. | CSS |
disp('data') | disp('data') | Correct. | MATLAB |
let count = 8; | let count = 8; | Correct. | JavaScript |
<p>value <b>test</p></b> | <p>value <b>test</b></p> | Nest properly. | HTML |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
if ($num = 80) | if ($num == 80) | Use ==. | Perl |
print 'output' | print('output') | print needs parentheses. | Python |
DELETE FROM products WHERE id=8 | DELETE FROM products WHERE id=8; | Add semicolon. | SQL |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(31); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(31); | Correct. | Node.js |
if ($count = 30) {{}} | if ($count -eq 30) {{}} | Use -eq. | PowerShell |
$foo = 11; if ($foo = 11) {{}} | $foo = 11; if ($foo == 11) {{}} | Use ==. | PHP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.