wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
{{'id':44, 'title' 99}} | {{'id':44, 'title':99}} | Colon missing. | Python |
let num: number | null = null; num.toFixed(99); | let num: number | null = null; if(num!==null) num.toFixed(99); | Null check. | TypeScript |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
if ($bar = 44) | if ($bar == 44) | Use ==. | Perl |
$data[45] | if ($data.Count -gt 45) {{ $data[45] }} | Check bounds. | PowerShell |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
let foo = 'world' | let foo = "world" | Double quotes. | Swift |
local item = 8 | local item = 8 | Correct. | Lua |
bar = 43 | bar=43 | No spaces. | Shell |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if index = 5 | if index == 5 | Use ==. | Go |
list.forEach(function(b) {{ console.log(b); }}) | list.forEach((b) => {{ console.log(b); }}) | Arrow functions are cleaner. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if (a = 78) | if (a == 78) | Use ==. | R |
function render(): void {{ return 56; }} | function render(): number {{ return 56; }} | Return type mismatch. | TypeScript |
disp('message') | disp('message') | Correct. | MATLAB |
math.sqrt(21) | import math
math.sqrt(21) | Import module first. | Python |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
if val = 30 | if val == 30 | Use ==. | MATLAB |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
items[27] | if (items.indices.contains(27)) items[27] | Check index. | Kotlin |
<hr></hr> | <hr> | Self-closing. | HTML |
for count in range(30)
print(count) | for count in range(30):
print(count) | Colon after for. | Python |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
foo | foo() | Add parentheses. | Swift |
if (bar = 30) | if (bar == 30) | Use ==. | C++ |
.Person {{ color: blue; }} | .Person {{ color: blue; }} | Correct. | CSS |
'data' + 96 | 'data' + str(96) | Can't add int to string. | Python |
print 'hello' | print('hello') | print needs parentheses. | Python |
if b > 40
puts 'hello' | if b > 40
puts 'hello'
end | Add 'end'. | Ruby |
jwt.sign({{id:64}}, 'token'); | jwt.sign({{id:64}}, 'token', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
JOIN orders ON items.id = orders.status | JOIN orders ON items.id = orders.status | Correct. | SQL |
print 'value' | print 'value'; | Add semicolon. | Perl |
else
print('data') | else:
print('data') | Colon after else. | Python |
'hello' + 99 | 'hello' + 99.to_s | Convert int. | Ruby |
var x = 4; | var x = 4; | Correct. | Dart |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
def process():
print('result') | def process():
print('result') | Indent function body. | Python |
List(5,64,82) | List(5,64,82) | Correct. | Scala |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
process | process() | Add parentheses. | Kotlin |
int val = 'output'; | String val = 'output'; | Type mismatch. | Dart |
function foo(b)
print(b)
end | function foo(b)
print(b)
end | Correct. | Lua |
<user name='data'/> | <user name="data"/> | Double quotes. | XML |
match index {{ 1 => {{}} }} | match index {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
["output", 92] | ["output", 92] | Correct. | JSON |
let foo: number = 'message'; | let foo: string = 'message'; | Fix type. | TypeScript |
function test(data:string){{return data;}} test(28); | function test(data:string){{return data;}} test('message'); | Pass correct type. | TypeScript |
let z = 93; | let z = 93; | Correct. | JavaScript |
<p>hello <b>data</p></b> | <p>hello <b>data</b></p> | Nest properly. | HTML |
if ($index = 65) {{}} | if ($index -eq 65) {{}} | Use -eq. | PowerShell |
'8' + 65 | 8 + 65 | Avoid string coercion. | JavaScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
if y = 94 | if y == 94 | Use ==. | Ruby |
DELETE FROM products WHERE age=81 | DELETE FROM products WHERE age=81; | Add semicolon. | SQL |
int[] values = new int[35];
values[35] = 5; | int[] values = new int[35];
if (35 < values.length) values[35] = 5; | Check bounds. | Java |
count = value | count = 'value' | Quote strings. | Python |
// comment | /* comment */ | Use /* */. | CSS |
<br></br> | <br> | Self-closing. | HTML |
String data = 'output'; | String data = "output"; | Double quotes. | Java |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if [ $a = 26 ]; then | if [ "$a" = 26 ]; then | Quote variable. | Shell |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
$list[70] = 5; | if (isset($list[70])) $list[70] = 5; | Check existence. | PHP |
items[30] | if (items.indices.contains(30)) items[30] | Check index. | Kotlin |
let result = 25; | let result = 25; | Correct. | JavaScript |
let s = String::from("hello"); let borrow=&s; s.push_str("!"); | let mut s = String::from("hello"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
class Order {{ int num; }}
obj.num=5; | class Order {{ public int num; }}
obj.num=5; | Make field public. | Java |
def test():
print('value') | def test():
print('value') | Indent function body. | Python |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
val count = 'info' | val count = "info" | Double quotes. | Kotlin |
int list[27]; list[27]=5; | int list[27]; if(27<27){{}} else list[27]=5; | Bounds check. | C++ |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
jwt.sign({{id:89}}, 'secret'); | jwt.sign({{id:89}}, 'secret', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
var x int | var x int | Correct. | Go |
if (result = 55) {{}} | if (result == 55) {{}} | Use ==. | Kotlin |
while data > 54
data -= 1 | while data > 54:
data -= 1 | Colon missing after while. | Python |
let str1 = String::from("info"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("info"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
x := 93 | x := 93 | Correct. | Go |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
let list=vec![83,97,6]; let first=&list[0]; list.push(81); | let mut list=vec![83,97,6]; let first=list[0]; list.push(81); | Copy instead of reference. | Rust |
INSERT INTO items VALUES ('message',50) | INSERT INTO items (id, role) VALUES ('message',50); | Specify columns. | SQL |
SELECT age status FROM items; | SELECT age, status FROM items; | Add comma. | SQL |
let z = 25; let z = 85; | let z = 25; z = 85; | Duplicate declaration. | JavaScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
b = data | b = 'data' | Quote strings. | Python |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
if (result = 81) | if (result == 81) | Use ==. | Scala |
function baz(item:string){{return item;}} baz(64); | function baz(item:string){{return item;}} baz('hello'); | Pass correct type. | TypeScript |
cin >> count; | int count;
cin >> count; | Declare variable. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.