wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<entry><name>value</name><age>43</age></entry | <entry><name>value</name><age>43</age></entry> | Add closing >. | XML |
if (temp = 92) {{}} | if (temp === 92) {{}} | Use === for equality. | JavaScript |
val temp = 'result' | val temp = "result" | Double quotes. | Kotlin |
function compute(num)
print(num)
end | function compute(num)
print(num)
end | Correct. | Lua |
if (y = 12) {{}} | if (y == 12) {{}} | Use ==. | Java |
<p>result <b>world</p></b> | <p>result <b>world</b></p> | Nest properly. | HTML |
render | render() | Add parentheses. | Swift |
else
print('value') | else:
print('value') | Colon after else. | Python |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
if ($y = 30) | if ($y == 30) | Use ==. | Perl |
$val = 38; if ($val = 38) {{}} | $val = 38; if ($val == 38) {{}} | Use ==. | PHP |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
<person age=95> | <person age="95"> | Quote attribute. | XML |
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 |
class Person {{ int temp; }}
obj.temp=5; | class Person {{ public int temp; }}
obj.temp=5; | Make field public. | Java |
values(45) | if length(values) >= 45, values(45), end | Check length. | MATLAB |
[x*x for x in items if x > 87] | [x*x for x in items if x > 87] | Correct list comprehension. | Python |
bar = world | bar = 'world' | Quote strings. | Python |
list[80] | if list.indices.contains(80) {{ list[80] }} | Check index. | Swift |
{{'title':66, 'id' 97}} | {{'title':66, 'id':97}} | Colon missing. | Python |
if b = 60 | if b == 60 | Use ==. | Ruby |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
int arr[91]; arr[91]=5; | int arr[91]; if(91<91){{}} else arr[91]=5; | Bounds check. | C++ |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let index: number | null = null; index.toFixed(57); | let index: number | null = null; if(index!==null) index.toFixed(57); | Null check. | TypeScript |
disp('hello') | disp('hello') | Correct. | MATLAB |
cin >> temp; | int temp;
cin >> temp; | Declare variable. | C++ |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
WHERE status = '74' | WHERE status = 74 | Don't quote integer. | SQL |
SELECT age status FROM orders; | SELECT age, status FROM orders; | Add comma. | SQL |
function test() {{
return
{{key:'hello'}}
}} | function test() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
re.sqrt(98) | import re
re.sqrt(98) | Import module first. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(68); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(68, () => console.log('listening')); | Add callback. | Node.js |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
if (b = 10) | if (b == 10) | Use ==. | Scala |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
val y = 54; y = 89 | var y = 54; y = 89 | Use var for reassignment. | Scala |
class Item {{ int a; }}; | class Item {{ public: int a; }}; | Make public. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<br></br> | <br> | Self-closing. | HTML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
a = 68 | a=68 | No spaces. | Shell |
data[85] | if (data.indices.contains(85)) data[85] | Check index. | Kotlin |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
name: result
age: 48 | name: result
age: 48 | Correct. | YAML |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
if bar = 93 {{}} | if bar == 93 {{}} | Use ==. | Swift |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
function render(): void {{ return 66; }} | function render(): number {{ return 66; }} | Return type mismatch. | TypeScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
int[] values = new int[82];
values[82] = 5; | int[] values = new int[82];
if (82 < values.length) values[82] = 5; | Check bounds. | Java |
if (foo = 18) | if (foo == 18) | Use ==. | C++ |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
local a = 86 | local a = 86 | Correct. | Lua |
def bar(x):
return x + 1 | def bar(x):
return x + 1 | Correct. | Python |
var x = 18; | var x = 18; | Correct. | Dart |
val data: Int = 'hello' | val data: String = 'hello' | Fix type. | Kotlin |
cin >> val
cout << val; | cin >> val;
cout << val; | Add semicolon. | C++ |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(70); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(70); | Correct. | Node.js |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
let s1 = String::from("test"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("test"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
[64, 46, 17 | [64, 46, 17] | Close bracket. | Ruby |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
y > 98 & z < 16 | y > 98 and z < 16 | Use 'and' not '&'. | Python |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
UPDATE products SET status='hello' WHERE status=98 | UPDATE products SET status='hello' WHERE status=98; | Add semicolon. | SQL |
var foo int = 'output' | var foo string = 'output' | Type mismatch. | Go |
assert result > 51 | assert result > 51 | Correct. | Python |
let data = 58; let data = 89; | let data = 58; data = 89; | Duplicate declaration. | JavaScript |
my @arr = (54,38,25); | my @arr = (54,38,25); | Correct. | Perl |
int bar = 'message'; | String bar = 'message'; | Type mismatch. | Dart |
{{"value":"world" "title":44}} | {{"value":"world", "title":44}} | Add comma. | JSON |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if index = 98 | if index == 98 | Use ==. | Go |
h1 {{ font-size:33px color:green; }} | h1 {{ font-size:33px; color:green; }} | Add semicolon. | CSS |
let count = 5; count += 1; | let mut count = 5; count += 1; | Need mut to modify. | Rust |
for (temp in list) | for (temp of list) | for...in iterates keys. | JavaScript |
x := 31 | x := 31 | Correct. | Go |
{{'name':'value'}} | {{"name":"value"}} | Use double quotes. | JSON |
let data: i32 = "data"; | let data: &str = "data"; | Type mismatch. | Rust |
'71' + 69 | 71 + 69 | Avoid string coercion. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
#footer {{ color: blue; }} | #footer {{ color: blue; }} | Correct. | CSS |
jwt.sign({{id:73}}, 'password'); | jwt.sign({{id:73}}, 'password', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
if a > 4
puts 'world' | if a > 4
puts 'world'
end | Add 'end'. | Ruby |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
val b: Int = 'result' | val b: String = 'result' | Fix type. | Kotlin |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
$values[89] = 5; | if (isset($values[89])) $values[89] = 5; | Check existence. | PHP |
object Order {{ def main(args: Array[String]) = println("output") }} | object Order {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
let v=vec![15,50,42]; let primary=&v[0]; v.push(63); | let mut v=vec![15,50,42]; let primary=v[0]; v.push(63); | Copy instead of reference. | Rust |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
.Product {{ color: green; }} | .Product {{ color: green; }} | Correct. | CSS |
id: hello
age: hello, | id: hello
age: hello | Remove comma. | YAML |
var x int | var x int | Correct. | Go |
["message", 15] | ["message", 15] | Correct. | JSON |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.