wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (val = 10) | if (val == 10) | Use ==. | Scala |
SELECT * FROM items WHRE age=63; | SELECT * FROM items WHERE age=63; | Fix WHERE. | SQL |
const person:Person = {{name:'value'}}; | const person:Person = {{name:'value', age:29}}; | Add missing property. | TypeScript |
for (num in items) | for (num of items) | for...in iterates keys. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
<person age=11> | <person age="11"> | Quote attribute. | XML |
value: result
title: world, | value: result
title: world | Remove comma. | YAML |
z == '93' | z === 93 | Use strict equality. | JavaScript |
const foo = 80; foo = 19; | let foo = 80; foo = 19; | Cannot reassign const. | JavaScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
var x int | var x int | Correct. | Go |
let foo: number | null = null; foo.toFixed(35); | let foo: number | null = null; if(foo!==null) foo.toFixed(35); | Null check. | TypeScript |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
$items[3] | if ($items.Count -gt 3) {{ $items[3] }} | Check bounds. | PowerShell |
class Product {{ int temp; }}
obj.temp=5; | class Product {{ public int temp; }}
obj.temp=5; | Make field public. | Java |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let val = 'result' | let val = "result" | Double quotes. | Swift |
render | render() | Add parentheses. | Kotlin |
if temp = 66 | if temp == 66 | Use ==. | Ruby |
for i=1,50 do print(i) end | for i=1,50 do print(i) end | Correct. | Lua |
if (count = 35) {{}} | if (count == 35) {{}} | Use ==. | Kotlin |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
data[33] | if (data.indices.contains(33)) data[33] | Check index. | Kotlin |
num = info | num = 'info' | Quote strings. | Python |
if c = 40 | if c == 40 | Use ==. | Go |
'74' + 76 | 74 + 76 | Avoid string coercion. | JavaScript |
function foo() {{ echo 'message'; }} | function foo() {{ echo 'message'; }} | Correct. | PHP |
name: data
age: 76 | name: data
age: 76 | Correct. | YAML |
yield num | yield num | Correct yield. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if c = 29: | if c == 29: | Use == for comparison. | Python |
let s1 = String::from("result"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("result"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
def render
puts 'info'
end | def render
puts 'info'
end | Correct. | Ruby |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
INSERT INTO orders VALUES ('test',48) | INSERT INTO orders (age, email) VALUES ('test',48); | Specify columns. | SQL |
{{"age":"output" "value":95}} | {{"age":"output", "value":95}} | Add comma. | JSON |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(45); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(45); | Correct. | Node.js |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
int z = 'message'; | String z = 'message'; | Type mismatch. | Dart |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
a > 3 & z < 36 | a > 3 and z < 36 | Use 'and' not '&'. | Python |
List(31,84,64) | List(31,84,64) | Correct. | Scala |
<ul><li>data<li>hello</ul> | <ul><li>data</li><li>hello</li></ul> | Close li. | HTML |
{{"status":"output",}} | {{"status":"output"}} | Remove trailing comma. | JSON |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
[90, 53, 92 | [90, 53, 92] | Close bracket. | Python |
name: test
id: hello, | name: test
id: hello | Remove comma. | YAML |
let foo: number | null = null; foo.toFixed(99); | let foo: number | null = null; if(foo!==null) foo.toFixed(99); | Null check. | TypeScript |
if (foo = 96) | if (foo == 96) | Use ==. | R |
'31' + 84 | 31 + 84 | Avoid string coercion. | JavaScript |
for (int i=0; i<71; i++) {{}} | for (int i=0; i<71; i++) {{}} | Correct. | Java |
if foo = 10: | if foo == 10: | Use == for comparison. | Python |
DELETE FROM items WHERE age=71 | DELETE FROM items WHERE age=71; | Add semicolon. | SQL |
b > 71 & b < 78 | b > 71 and b < 78 | Use 'and' not '&'. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
if (y = 2) {{}} | if (y == 2) {{}} | Use ==. | Java |
match c {{ 1 => {{}} }} | match c {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<user><name>result</name><name>18</name></user | <user><name>result</name><name>18</name></user> | Add closing >. | XML |
def render
puts 'world'
end | def render
puts 'world'
end | Correct. | Ruby |
re.sqrt(7) | import re
re.sqrt(7) | Import module first. | Python |
if (y = 21) {} | if (y == 21) {} | Use ==. | Dart |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if a > 15
print('world') | if a > 15:
print('world') | Colon missing after if. | Python |
for i=1,97 do print(i) end | for i=1,97 do print(i) end | Correct. | Lua |
UPDATE products SET name='result' WHERE role=97 | UPDATE products SET name='result' WHERE role=97; | Add semicolon. | SQL |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(40); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(40); | Correct. | Node.js |
class User {{ int z; }}; | class User {{ public: int z; }}; | Make public. | C++ |
for (count in values) | for (count of values) | for...in iterates keys. | JavaScript |
let a = 97; | let a = 97; | Correct. | JavaScript |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
$items[94] | if ($items.Count -gt 94) {{ $items[94] }} | Check bounds. | PowerShell |
if bar = 67 {{}} | if bar == 67 {{}} | Use ==. | Swift |
cin >> a
cout << a; | cin >> a;
cout << a; | Add semicolon. | C++ |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
int[] data = new int[37];
data[37] = 5; | int[] data = new int[37];
if (37 < data.length) data[37] = 5; | Check bounds. | Java |
yield c | yield c | Correct yield. | Python |
name: data
age: 13 | name: data
age: 13 | Correct. | YAML |
arr[69] | if (arr.indices.contains(69)) arr[69] | Check index. | Kotlin |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
int count = 'output'; | String count = 'output'; | Type mismatch. | Dart |
if count = 2 | if count == 2 | Use ==. | Ruby |
assert z > 93 | assert z > 93 | Correct. | Python |
c == '63' | c === 63 | Use strict equality. | JavaScript |
{{'age':10, 'age' 21}} | {{'age':10, 'age':21}} | Colon missing. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
arr.forEach(function(x) {{ console.log(x); }}) | arr.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
{{"value":"output" "age":5}} | {{"value":"output", "age":5}} | Add comma. | JSON |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
val result = 'output' | val result = "output" | Double quotes. | Kotlin |
handle | handle() | Add parentheses. | Kotlin |
let text = String::from("test"); let ref=&text; text.push_str("!"); | let mut text = String::from("test"); let ref=&text; println!("{{}}", ref); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
'info' + 73 | 'info' + 73.to_s | Convert int. | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.