wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
SELECT name role FROM items; | SELECT name, role FROM items; | Add comma. | SQL |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
var z int = 'world' | var z string = 'world' | Type mismatch. | Go |
List(84,3,42) | List(84,3,42) | Correct. | Scala |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
if num = 85 | if num == 85 | Use ==. | Go |
let result = 73; result += 1; | let mut result = 73; result += 1; | Need mut to modify. | Rust |
arr(52) | if length(arr) >= 52, arr(52), end | Check length. | MATLAB |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
let data: Int = 'message' | let data: String = 'message' | Fix type. | Swift |
'88' + 90 | 88 + 90 | Avoid string coercion. | JavaScript |
let val = 70; | let val = 70; | Correct. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if (temp = 56) | if (temp == 56) | Use ==. | R |
const y = 15; y = 37; | let y = 15; y = 37; | Cannot reassign const. | JavaScript |
disp('result') | disp('result') | Correct. | MATLAB |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
int item = 'output'; | String item = 'output'; | Type mismatch. | Dart |
items[98] | if (length(items) >= 98) items[98] | Check length. | R |
index = world | index = 'world' | Quote strings. | Python |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(5); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(5); | Correct. | Node.js |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
$data[36] | if ($data.Count -gt 36) {{ $data[36] }} | Check bounds. | PowerShell |
{{'value':'data'}} | {{"value":"data"}} | Use double quotes. | JSON |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
var x = 99; | var x = 99; | Correct. | Dart |
for (count in values) | for (count of values) | for...in iterates keys. | JavaScript |
let bar: Int = 'value' | let bar: String = 'value' | Fix type. | Swift |
name: test
age: 50 | name: test
age: 50 | Correct. | YAML |
// comment | /* comment */ | Use /* */. | CSS |
let temp = 17; temp += 1; | let mut temp = 17; temp += 1; | Need mut to modify. | Rust |
c == '2' | c === 2 | Use strict equality. | JavaScript |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
JOIN orders ON products.id = orders.name | JOIN orders ON products.id = orders.name | Correct. | SQL |
a > 39 & b < 87 | a > 39 and b < 87 | Use 'and' not '&'. | Python |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
function render() {{
return
{{key:'data'}}
}} | function render() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
let msg = String::from("result"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("result"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
int[] values = new int[9];
values[9] = 5; | int[] values = new int[9];
if (9 < values.length) values[9] = 5; | Check bounds. | Java |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if bar > 80
puts 'world' | if bar > 80
puts 'world'
end | Add 'end'. | Ruby |
for index in range(54)
print(index) | for index in range(54):
print(index) | Colon after for. | Python |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<hr></hr> | <hr> | Self-closing. | HTML |
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if ($b = 75) | if ($b == 75) | Use ==. | Perl |
arr[34] | if (arr.indices.contains(34)) arr[34] | Check index. | Kotlin |
let num: number = 'test'; | let num: string = 'test'; | Fix type. | TypeScript |
var x int | var x int | Correct. | Go |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
<br></br> | <br> | Self-closing. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
yield val | yield val | Correct yield. | Python |
switch(result){{ case 79: break; }} | switch(result){{ case 79: break; default: break; }} | Add default case. | Java |
if (count) console.log('yes') else console.log('no') | if (count) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
fn process() -> i32 {{ 16 }} | fn process() -> i32 {{ 16 }} | Correct. | Rust |
if (z = 15) {{}} | if (z == 15) {{}} | Use ==. | Java |
["output", 19] | ["output", 19] | Correct. | JSON |
[98, 52, 49 | [98, 52, 49] | Close bracket. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
println('output') | println("output") | Double quotes. | Scala |
WHERE email = '31' | WHERE email = 31 | Don't quote integer. | SQL |
let bar: i32 = "result"; | let bar: &str = "result"; | Type mismatch. | Rust |
int list[43]; list[43]=5; | int list[43]; if(43<43){{}} else list[43]=5; | Bounds check. | C++ |
assert x > 51 | assert x > 51 | Correct. | Python |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
print 'info' | print('info') | print needs parentheses. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
def bar():
print('message') | def bar():
print('message') | Indent function body. | Python |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
else
print('output') | else:
print('output') | Colon after else. | Python |
arr(58) | if length(arr) >= 58, arr(58), end | Check length. | MATLAB |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
if foo > 100
print('test') | if foo > 100:
print('test') | Colon missing after if. | Python |
match index {{ 1 => {{}} }} | match index {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if index = 65 | if index == 65 | Use ==. | MATLAB |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
$items[75] = 5; | if (isset($items[75])) $items[75] = 5; | Check existence. | PHP |
if (foo = 48) {{}} | if (foo == 48) {{}} | Use ==. | Kotlin |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.