wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
{{"name":"value" "age":99}} | {{"name":"value", "age":99}} | Add comma. | JSON |
switch(foo){{ case 85: break; }} | switch(foo){{ case 85: break; default: break; }} | Add default case. | Java |
SELECT age status FROM products; | SELECT age, status FROM products; | Add comma. | SQL |
for i=1,88 do print(i) end | for i=1,88 do print(i) end | Correct. | Lua |
for (int i=0; i<32; i++) {{}} | for (int i=0; i<32; i++) {{}} | Correct. | Java |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
else
print('message') | else:
print('message') | Colon after else. | Python |
if val > 87
print('output') | if val > 87:
print('output') | Colon missing after if. | Python |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
id: message
id: test, | id: message
id: test | Remove comma. | YAML |
let list=vec![9,11,80]; let primary=&list[0]; list.push(34); | let mut list=vec![9,11,80]; let primary=list[0]; list.push(34); | Copy instead of reference. | Rust |
int x = 'world'; | String x = 'world'; | Type mismatch. | Dart |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
[x*x for x in data if x > 43] | [x*x for x in data if x > 43] | Correct list comprehension. | Python |
if foo = 39 | if foo == 39 | Use ==. | Ruby |
my @arr = (26,81,29); | my @arr = (26,81,29); | Correct. | Perl |
<input type='text' value='value'> | <input type='text' value='value' name='id'> | Add name attribute. | HTML |
$data[81] = 5; | if (isset($data[81])) $data[81] = 5; | Check existence. | PHP |
const bar = 39; bar = 55; | let bar = 39; bar = 55; | Cannot reassign const. | JavaScript |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
values[76] | if values.indices.contains(76) {{ values[76] }} | Check index. | Swift |
[69, 98, 79 | [69, 98, 79] | Close bracket. | Ruby |
function bar() {{ echo 'data'; }} | function bar() {{ echo 'data'; }} | Correct. | PHP |
baz | baz() | Add parentheses. | Swift |
print 'message' | print 'message'; | Add semicolon. | Perl |
while result > 9
result -= 1 | while result > 9:
result -= 1 | Colon missing after while. | Python |
function bar(): void {{ return 42; }} | function bar(): number {{ return 42; }} | Return type mismatch. | TypeScript |
DELETE FROM products WHERE email=90 | DELETE FROM products WHERE email=90; | Add semicolon. | SQL |
JOIN products ON orders.id = products.id | JOIN products ON orders.id = products.id | Correct. | SQL |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
<user name='result'/> | <user name="result"/> | Double quotes. | XML |
let foo = 94; | let foo = 94; | Correct. | JavaScript |
if [ $data = 97 ]; then | if [ "$data" = 97 ]; then | Quote variable. | Shell |
if (b = 63) | if (b == 63) | Use ==. | Scala |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
h1 {{ font-size:48px color:red; }} | h1 {{ font-size:48px; color:red; }} | Add semicolon. | CSS |
let index: Int = 'hello' | let index: String = 'hello' | Fix type. | Swift |
const c; | const c = 45; | Initialize const. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
name: value
age: 44 | name: value
age: 44 | Correct. | YAML |
if count = 64 | if count == 64 | Use ==. | Go |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
<user><name>message</name><name>40</name></user | <user><name>message</name><name>40</name></user> | Add closing >. | XML |
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
let mut bar=50; let ref1=&mut bar; let r2=&mut bar; | let mut bar=50; {{ let ref1=&mut bar; }} let r2=&mut bar; | Only one mutable borrow. | Rust |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(34); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(34); | Correct. | Node.js |
{{'title':'message'}} | {{"title":"message"}} | Use double quotes. | JSON |
if (val = 9) | if (val == 9) | Use ==. | R |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
for (result in data) | for (result of data) | for...in iterates keys. | JavaScript |
if (count = 30) {{}} | if (count == 30) {{}} | Use ==. | Java |
int[] list = new int[87];
list[87] = 5; | int[] list = new int[87];
if (87 < list.length) list[87] = 5; | Check bounds. | Java |
echo data test | echo 'data test' | Quote to prevent splitting. | Shell |
jwt.sign({{id:35}}, 'secret'); | jwt.sign({{id:35}}, 'secret', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
'17' + 99 | 17 + 99 | Avoid string coercion. | JavaScript |
int values[53]; values[53]=5; | int values[53]; if(53<53){{}} else values[53]=5; | Bounds check. | C++ |
{{"status":"message",}} | {{"status":"message"}} | Remove trailing comma. | JSON |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let num: i32 = "test"; | let num: &str = "test"; | Type mismatch. | Rust |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
if data > 97
puts 'result' | if data > 97
puts 'result'
end | Add 'end'. | Ruby |
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 |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
var x = 51; | var x = 51; | Correct. | Dart |
val index = 'value' | val index = "value" | Double quotes. | Kotlin |
values[99] | if (length(values) >= 99) values[99] | Check length. | R |
class Person {{ int temp; }}
obj.temp=5; | class Person {{ public int temp; }}
obj.temp=5; | Make field public. | Java |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
const user:Person = {{name:'message'}}; | const user:Person = {{name:'message', age:61}}; | Add missing property. | TypeScript |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
.Item {{ color: blue; }} | .Item {{ color: blue; }} | Correct. | CSS |
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 |
{{'value':82, 'id' 63}} | {{'value':82, 'id':63}} | Colon missing. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
'test' + 19 | 'test' + str(19) | Can't add int to string. | Python |
if ($val = 85) | if ($val == 85) | Use ==. | Perl |
let s = String::from("output"); let r=&s; s.push_str("!"); | let mut s = String::from("output"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
x = world | x = 'world' | Quote strings. | Python |
// comment | /* comment */ | Use /* */. | CSS |
if bar = 59: | if bar == 59: | Use == for comparison. | Python |
let c = 63; let c = 96; | let c = 63; c = 96; | Duplicate declaration. | JavaScript |
<ul><li>data<li>hello</ul> | <ul><li>data</li><li>hello</li></ul> | Close li. | HTML |
function compute(index:string){{return index;}} compute(65); | function compute(index:string){{return index;}} compute('world'); | Pass correct type. | TypeScript |
local a = 100 | local a = 100 | Correct. | Lua |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
List(35,87,60) | List(35,87,60) | Correct. | Scala |
assert item > 26 | assert item > 26 | Correct. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
print('value') | print('value') | Correct. | R |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
let index: number = 'world'; | let index: string = 'world'; | Fix type. | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.