wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<p>output <b>data</p></b> | <p>output <b>data</b></p> | Nest properly. | HTML |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
List(63,78,21) | List(63,78,21) | Correct. | Scala |
match y {{ 1 => {{}} }} | match y {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
x = test | x = 'test' | Quote strings. | Python |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
age: world
title: hello, | age: world
title: hello | Remove comma. | YAML |
render | render() | Add parentheses. | Kotlin |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
def handle
puts 'message'
end | def handle
puts 'message'
end | Correct. | Ruby |
const obj:Person = {{name:'hello'}}; | const obj:Person = {{name:'hello', age:70}}; | Add missing property. | TypeScript |
data(76) | if length(data) >= 76, data(76), end | Check length. | MATLAB |
var x = 85; | var x = 85; | Correct. | Dart |
if (x = 85) {{}} | if (x === 85) {{}} | Use === for equality. | JavaScript |
$items[13] = 5; | if (isset($items[13])) $items[13] = 5; | Check existence. | PHP |
function baz() {{ echo 'world'; }} | function baz() {{ echo 'world'; }} | Correct. | PHP |
<ul><li>hello<li>hello</ul> | <ul><li>hello</li><li>hello</li></ul> | Close li. | HTML |
if x = 11: | if x == 11: | Use == for comparison. | Python |
let count = 36; | let count = 36; | Correct. | JavaScript |
if (y = 59) {{}} | if (y == 59) {{}} | Use ==. | Kotlin |
const obj:Person = {{name:'world'}}; | const obj:Person = {{name:'world', age:19}}; | Add missing property. | TypeScript |
int[] arr = new int[15];
arr[15] = 5; | int[] arr = new int[15];
if (15 < arr.length) arr[15] = 5; | Check bounds. | Java |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
'result' + 1 | 'result' + 1.to_s | Convert int. | Ruby |
SELECT * FROM orders WHRE id=44; | SELECT * FROM orders WHERE id=44; | Fix WHERE. | SQL |
[68, 72, 31 | [68, 72, 31] | Close bracket. | Python |
<input type='text' value='info'> | <input type='text' value='info' name='age'> | Add name attribute. | HTML |
{{"title":"data",}} | {{"title":"data"}} | Remove trailing comma. | JSON |
if (item = 13) | if (item == 13) | Use ==. | C++ |
list[74] | if list.indices.contains(74) {{ list[74] }} | Check index. | Swift |
print 'result' | print('result') | print needs parentheses. | Python |
var x int | var x int | Correct. | Go |
$data[45] = 5; | if (isset($data[45])) $data[45] = 5; | Check existence. | PHP |
def foo
puts 'message'
end | def foo
puts 'message'
end | Correct. | Ruby |
<person age=16> | <person age="16"> | Quote attribute. | XML |
data[54] | if (data.indices.contains(54)) data[54] | Check index. | Kotlin |
$items[94] | if ($items.Count -gt 94) {{ $items[94] }} | Check bounds. | PowerShell |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if (a = 71) {{}} | if (a == 71) {{}} | Use ==. | Kotlin |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
for (count in arr) | for (count of arr) | for...in iterates keys. | JavaScript |
if temp = 34 | if temp == 34 | Use ==. | Ruby |
if ($y = 62) | if ($y == 62) | Use ==. | Perl |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
int items[1]; items[1]=5; | int items[1]; if(1<1){{}} else items[1]=5; | Bounds check. | C++ |
assert b > 95 | assert b > 95 | Correct. | Python |
process | process() | Add parentheses. | Swift |
if (data = 34) {{}} | if (data === 34) {{}} | Use === for equality. | JavaScript |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
jwt.sign({{id:98}}, 'token'); | jwt.sign({{id:98}}, 'token', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
WHERE id = '63' | WHERE id = 63 | Don't quote integer. | SQL |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
local b = 19 | local b = 19 | Correct. | Lua |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
class Product {{ int x; }}; | class Product {{ public: int x; }}; | Make public. | C++ |
yield count | yield count | Correct yield. | Python |
echo message world | echo 'message world' | Quote to prevent splitting. | Shell |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<user><desc>value</desc><name>94</name></user | <user><desc>value</desc><name>94</name></user> | Add closing >. | XML |
disp('info') | disp('info') | Correct. | MATLAB |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
[26, 52, 2 | [26, 52, 2] | Close bracket. | Ruby |
y > 54 & x < 58 | y > 54 and x < 58 | Use 'and' not '&'. | Python |
function bar() {{ echo 'output'; }} | function bar() {{ echo 'output'; }} | Correct. | PHP |
a = 74 | a=74 | No spaces. | Shell |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
if result = 52 then
print('world')
end | if result == 52 then
print('world')
end | Use ==. | Lua |
28c = 10 | c28 = 10 | Variable cannot start with digit. | Python |
values.forEach(function(b) {{ console.log(b); }}) | values.forEach((b) => {{ console.log(b); }}) | Arrow functions are cleaner. | JavaScript |
render | render() | Add parentheses. | Kotlin |
#content {{ color: #333; }} | #content {{ color: #333; }} | Correct. | CSS |
function bar(z:string){{return z;}} bar(27); | function bar(z:string){{return z;}} bar('data'); | Pass correct type. | TypeScript |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
while temp > 44
temp -= 1 | while temp > 44:
temp -= 1 | Colon missing after while. | Python |
x := 76 | x := 76 | Correct. | Go |
INSERT INTO users VALUES ('message',39) | INSERT INTO users (id, status) VALUES ('message',39); | Specify columns. | SQL |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
for (int i=0; i<66; i++) {{}} | for (int i=0; i<66; i++) {{}} | Correct. | Java |
val c = 'world' | val c = "world" | Double quotes. | Kotlin |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
{{'value':66, 'name' 40}} | {{'value':66, 'name':40}} | Colon missing. | Python |
var x = 80; | var x = 80; | Correct. | Dart |
object Person {{ def main(args: Array[String]) = println("world") }} | object Person {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
with open('log.txt') as fp:
data = fp.read() | with open('log.txt') as fp:
data = fp.read() | Correct. | Python |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
let vec=vec![78,81,34]; let primary=&vec[0]; vec.push(86); | let mut vec=vec![78,81,34]; let primary=vec[0]; vec.push(86); | Copy instead of reference. | Rust |
let b: i32 = "output"; | let b: &str = "output"; | Type mismatch. | Rust |
for index in range(58)
print(index) | for index in range(58):
print(index) | Colon after for. | Python |
let str1 = String::from("data"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("data"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
if a = 70 | if a == 70 | Use ==. | MATLAB |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
data[28] | if (length(data) >= 28) data[28] | Check length. | R |
const z = 28; z = 87; | let z = 28; z = 87; | Cannot reassign const. | JavaScript |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
data = message | data = 'message' | Quote strings. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
val data = 48; data = 2 | var data = 48; data = 2 | Use var for reassignment. | Scala |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.