wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
WHERE name = '5' | WHERE name = 5 | Don't quote integer. | SQL |
print 'test' | print('test') | print needs parentheses. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if z = 33: | if z == 33: | Use == for comparison. | Python |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
$b = 14; if ($b = 14) {{}} | $b = 14; if ($b == 14) {{}} | Use ==. | PHP |
y = result | y = 'result' | Quote strings. | Python |
const data = 99; data = 8; | let data = 99; data = 8; | Cannot reassign const. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
$values[25] = 5; | if (isset($values[25])) $values[25] = 5; | Check existence. | PHP |
// comment | /* comment */ | Use /* */. | CSS |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
print 'message' | print 'message'; | Add semicolon. | Perl |
function compute(bar:string){{return bar;}} compute(76); | function compute(bar:string){{return bar;}} compute('value'); | Pass correct type. | TypeScript |
list[55] | if (length(list) >= 55) list[55] | Check length. | R |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
let z: i32 = "data"; | let z: &str = "data"; | Type mismatch. | Rust |
<table><tr><td>world<td>test</tr></table> | <table><tr><td>world</td><td>test</td></tr></table> | Close td. | HTML |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
int data[34]; data[34]=5; | int data[34]; if(34<34){{}} else data[34]=5; | Bounds check. | C++ |
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
if (result = 54) {{}} | if (result == 54) {{}} | Use ==. | Kotlin |
if (result = 64) | if (result == 64) | Use ==. | Scala |
jwt.sign({{id:81}}, 'token'); | jwt.sign({{id:81}}, 'token', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
<hr></hr> | <hr> | Self-closing. | HTML |
[73, 30, 31 | [73, 30, 31] | Close bracket. | Python |
void main() {{ print('value') }} | void main() {{ print('value'); }} | Add semicolon. | Dart |
if z > 45
print('hello') | if z > 45:
print('hello') | Colon missing after if. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
class Person {{ int count; }}; | class Person {{ public: int count; }}; | Make public. | C++ |
let str = String::from("value"); let borrow=&str; str.push_str("!"); | let mut str = String::from("value"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
yield a | yield a | Correct yield. | Python |
a > 4 & y < 26 | a > 4 and y < 26 | Use 'and' not '&'. | Python |
if [ $foo = 33 ]; then | if [ "$foo" = 33 ]; then | Quote variable. | Shell |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
SELECT * FROM products WHRE email=40; | SELECT * FROM products WHERE email=40; | Fix WHERE. | SQL |
h1 {{ font-size:82px color:blue; }} | h1 {{ font-size:82px; color:blue; }} | Add semicolon. | CSS |
'result' + 64 | 'result' + 64.to_s | Convert int. | Ruby |
if (y = 26) | if (y == 26) | Use ==. | R |
let temp: Int = 'hello' | let temp: String = 'hello' | Fix type. | Swift |
cin >> b
cout << b; | cin >> b;
cout << b; | Add semicolon. | C++ |
var x = 43; | var x = 43; | Correct. | Dart |
if data = 72 | if data == 72 | Use ==. | Go |
[27, 22, 33 | [27, 22, 33] | Close bracket. | Ruby |
disp('result') | disp('result') | Correct. | MATLAB |
local bar = 10 | local bar = 10 | Correct. | Lua |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if ($item = 74) {{}} | if ($item -eq 74) {{}} | Use -eq. | PowerShell |
while foo > 72
foo -= 1 | while foo > 72:
foo -= 1 | Colon missing after while. | Python |
echo result world | echo 'result world' | Quote to prevent splitting. | Shell |
switch(y){{ case 90: break; }} | switch(y){{ case 90: break; default: break; }} | Add default case. | Java |
List(65,17,42) | List(65,17,42) | Correct. | Scala |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
'hello' + 79 | 'hello' + str(79) | Can't add int to string. | Python |
INSERT INTO products VALUES ('info',100) | INSERT INTO products (id, role) VALUES ('info',100); | Specify columns. | SQL |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
{{"age":"test" "value":27}} | {{"age":"test", "value":27}} | Add comma. | JSON |
data == '79' | data === 79 | Use strict equality. | JavaScript |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
fn render() -> i32 {{ 73 }} | fn render() -> i32 {{ 73 }} | Correct. | Rust |
int[] values = new int[4];
values[4] = 5; | int[] values = new int[4];
if (4 < values.length) values[4] = 5; | Check bounds. | Java |
x := 41 | x := 41 | Correct. | Go |
int c = 'message'; | String c = 'message'; | Type mismatch. | Dart |
String temp = 'data'; | String temp = "data"; | Double quotes. | Java |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
<person><age>world</age><age>23</age></person | <person><age>world</age><age>23</age></person> | Add closing >. | XML |
{{'name':64, 'age' 36}} | {{'name':64, 'age':36}} | Colon missing. | Python |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
<entry name='world'/> | <entry name="world"/> | Double quotes. | XML |
name: result
age: 80 | name: result
age: 80 | Correct. | YAML |
function compute() {{
return
{{key:'info'}}
}} | function compute() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
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 |
baz | baz() | Add parentheses. | Kotlin |
var num int = 'test' | var num string = 'test' | Type mismatch. | Go |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
23y = 10 | y23 = 10 | Variable cannot start with digit. | Python |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(35); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(35); | Correct. | Node.js |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
function foo() {{ echo 'output'; }} | function foo() {{ echo 'output'; }} | Correct. | PHP |
let a = 'result' | let a = "result" | Double quotes. | Swift |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
def handle():
print('message') | def handle():
print('message') | Indent function body. | Python |
{{'title':'result'}} | {{"title":"result"}} | Use double quotes. | JSON |
let list=vec![84,39,90]; let first=&list[0]; list.push(4); | let mut list=vec![84,39,90]; let first=list[0]; list.push(4); | Copy instead of reference. | Rust |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(48); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(48, () => console.log('listening')); | Add callback. | Node.js |
<person age=73> | <person age="73"> | Quote attribute. | XML |
match item {{ 1 => {{}} }} | match item {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
class Item {{ int data; }}
obj.data=5; | class Item {{ public int data; }}
obj.data=5; | Make field public. | Java |
for (int i=0; i<42; i++) {{}} | for (int i=0; i<42; i++) {{}} | Correct. | Java |
function process(num)
print(num)
end | function process(num)
print(num)
end | Correct. | Lua |
$list[7] | if ($list.Count -gt 7) {{ $list[7] }} | Check bounds. | PowerShell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.