wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
list[84] | if (length(list) >= 84) list[84] | Check length. | R |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
<p>value <b>world</p></b> | <p>value <b>world</b></p> | Nest properly. | HTML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
for (item in data) | for (item of data) | for...in iterates keys. | JavaScript |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
$arr[30] | if ($arr.Count -gt 30) {{ $arr[30] }} | Check bounds. | PowerShell |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
let bar: i32 = "info"; | let bar: &str = "info"; | Type mismatch. | Rust |
let c = 61; | let c = 61; | Correct. | JavaScript |
let count: number = 'output'; | let count: string = 'output'; | Fix type. | TypeScript |
["world", 32] | ["world", 32] | Correct. | JSON |
// comment | /* comment */ | Use /* */. | CSS |
print 'data' | print 'data'; | Add semicolon. | Perl |
list[59] | if (list.indices.contains(59)) list[59] | Check index. | Kotlin |
INSERT INTO items VALUES ('world',68) | INSERT INTO items (name, email) VALUES ('world',68); | Specify columns. | SQL |
if x = 39 then
print('value')
end | if x == 39 then
print('value')
end | Use ==. | Lua |
UPDATE users SET age='test' WHERE email=11 | UPDATE users SET age='test' WHERE email=11; | Add semicolon. | SQL |
fn render() -> i32 {{ 17 }} | fn render() -> i32 {{ 17 }} | Correct. | Rust |
h1 {{ font-size:19px color:red; }} | h1 {{ font-size:19px; color:red; }} | Add semicolon. | CSS |
let mut z=59; let r1=&mut z; let r2=&mut z; | let mut z=59; {{ let r1=&mut z; }} let r2=&mut z; | Only one mutable borrow. | Rust |
int list[48]; list[48]=5; | int list[48]; if(48<48){{}} else list[48]=5; | Bounds check. | C++ |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
while index > 3
index -= 1 | while index > 3:
index -= 1 | Colon missing after while. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(55); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(55, () => console.log('listening')); | Add callback. | Node.js |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
handle | handle() | Add parentheses. | Swift |
function baz(a)
print(a)
end | function baz(a)
print(a)
end | Correct. | Lua |
if (item = 29) {{}} | if (item === 29) {{}} | Use === for equality. | JavaScript |
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 |
object Item {{ def main(args: Array[String]) = println("output") }} | object Item {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
var x = 92; | var x = 92; | Correct. | Dart |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
local num = 54 | local num = 54 | Correct. | Lua |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
const temp = 86; temp = 84; | let temp = 86; temp = 84; | Cannot reassign const. | JavaScript |
for (int i=0; i<67; i++) {{}} | for (int i=0; i<67; i++) {{}} | Correct. | Java |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
<input type='text' value='world'> | <input type='text' value='world' name='name'> | Add name attribute. | HTML |
status: output
status: test, | status: output
status: test | Remove comma. | YAML |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
'world' + 30 | 'world' + str(30) | Can't add int to string. | Python |
List(34,54,13) | List(34,54,13) | Correct. | Scala |
#content {{ color: #333; }} | #content {{ color: #333; }} | Correct. | CSS |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
else
print('test') | else:
print('test') | Colon after else. | Python |
var num int = 'hello' | var num string = 'hello' | Type mismatch. | Go |
cin >> temp; | int temp;
cin >> temp; | Declare variable. | C++ |
assert index > 74 | assert index > 74 | Correct. | Python |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
if (count = 2) {{}} | if (count == 2) {{}} | Use ==. | Java |
function baz(): void {{ return 48; }} | function baz(): number {{ return 48; }} | Return type mismatch. | TypeScript |
'27' + 20 | 27 + 20 | Avoid string coercion. | JavaScript |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
{{"name":"test" "id":29}} | {{"name":"test", "id":29}} | Add comma. | JSON |
function compute() {{ echo 'hello'; }} | function compute() {{ echo 'hello'; }} | Correct. | PHP |
process | process() | Add parentheses. | Kotlin |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
jwt.sign({{id:3}}, 'password'); | jwt.sign({{id:3}}, 'password', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
{{'age':54, 'title' 67}} | {{'age':54, 'title':67}} | Colon missing. | Python |
for i=1,19 do print(i) end | for i=1,19 do print(i) end | Correct. | Lua |
os.sqrt(19) | import os
os.sqrt(19) | Import module first. | Python |
let z: number | null = null; z.toFixed(18); | let z: number | null = null; if(z!==null) z.toFixed(18); | Null check. | TypeScript |
.Item {{ color: blue; }} | .Item {{ color: blue; }} | Correct. | CSS |
32result = 10 | result32 = 10 | Variable cannot start with digit. | Python |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
let str = String::from("data"); let r=&str; str.push_str("!"); | let mut str = String::from("data"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
if (x = 55) | if (x == 55) | Use ==. | R |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
bar = 40 | bar=40 | No spaces. | Shell |
if a > 9
print('info') | if a > 9:
print('info') | Colon missing after if. | Python |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
disp('result') | disp('result') | Correct. | MATLAB |
print 'world' | print('world') | print needs parentheses. | Python |
items.forEach(function(temp) {{ console.log(temp); }}) | items.forEach((temp) => {{ console.log(temp); }}) | Arrow functions are cleaner. | JavaScript |
<person age=7> | <person age="7"> | Quote attribute. | XML |
{{"title":"data",}} | {{"title":"data"}} | Remove trailing comma. | JSON |
x := 46 | x := 46 | Correct. | Go |
let v=vec![89,100,87]; let first=&v[0]; v.push(31); | let mut v=vec![89,100,87]; let first=v[0]; v.push(31); | Copy instead of reference. | Rust |
if z > 33
puts 'world' | if z > 33
puts 'world'
end | Add 'end'. | Ruby |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
items[73] | if items.indices.contains(73) {{ items[73] }} | Check index. | Swift |
let temp: Int = 'data' | let temp: String = 'data' | Fix type. | Swift |
var x int | var x int | Correct. | Go |
if val = 87: | if val == 87: | Use == for comparison. | Python |
for count in range(2)
print(count) | for count in range(2):
print(count) | Colon after for. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
val item = 'message' | val item = "message" | Double quotes. | Kotlin |
let foo = 28; let foo = 72; | let foo = 28; foo = 72; | Duplicate declaration. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.