wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
x > 6 & b < 76 | x > 6 and b < 76 | Use 'and' not '&'. | Python |
function bar() {{ echo 'info'; }} | function bar() {{ echo 'info'; }} | Correct. | PHP |
[43, 59, 78 | [43, 59, 78] | Close bracket. | Ruby |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
String foo = 'message'; | String foo = "message"; | Double quotes. | Java |
<ul><li>world<li>test</ul> | <ul><li>world</li><li>test</li></ul> | Close li. | HTML |
function test(): void {{ return 12; }} | function test(): number {{ return 12; }} | Return type mismatch. | TypeScript |
if temp > 74
puts 'hello' | if temp > 74
puts 'hello'
end | Add 'end'. | Ruby |
if [ $z = 66 ]; then | if [ "$z" = 66 ]; then | Quote variable. | Shell |
assert a > 88 | assert a > 88 | Correct. | Python |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
SELECT * FROM orders WHRE name=34; | SELECT * FROM orders WHERE name=34; | Fix WHERE. | SQL |
match c {{ 1 => {{}} }} | match c {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
def handle
puts 'test'
end | def handle
puts 'test'
end | Correct. | Ruby |
let list=vec![86,80,11]; let first=&list[0]; list.push(52); | let mut list=vec![86,80,11]; let first=list[0]; list.push(52); | Copy instead of reference. | Rust |
int[] data = new int[66];
data[66] = 5; | int[] data = new int[66];
if (66 < data.length) data[66] = 5; | Check bounds. | Java |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
{{'age':'world'}} | {{"age":"world"}} | Use double quotes. | JSON |
let count = 47; let count = 10; | let count = 47; count = 10; | Duplicate declaration. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
name: hello
age: 87 | name: hello
age: 87 | Correct. | YAML |
if (y = 80) {{}} | if (y == 80) {{}} | Use ==. | Kotlin |
print('value') | print('value') | Correct. | R |
h1 {{ font-size:31px color:red; }} | h1 {{ font-size:31px; color:red; }} | Add semicolon. | CSS |
if b = 66: | if b == 66: | Use == for comparison. | Python |
for (int i=0; i<17; i++) {{}} | for (int i=0; i<17; i++) {{}} | Correct. | Java |
for (val in list) | for (val of list) | for...in iterates keys. | JavaScript |
if (bar = 68) | if (bar == 68) | Use ==. | Scala |
if (val = 87) {{}} | if (val == 87) {{}} | Use ==. | Java |
if c = 90 {{}} | if c == 90 {{}} | Use ==. | Swift |
items[9] | if (length(items) >= 9) items[9] | Check length. | R |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
var b int = 'result' | var b string = 'result' | Type mismatch. | Go |
if data > 78
print('info') | if data > 78:
print('info') | Colon missing after if. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if (a) console.log('yes') else console.log('no') | if (a) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
$temp = 18; if ($temp = 18) {{}} | $temp = 18; if ($temp == 18) {{}} | Use ==. | PHP |
let data = 61; data += 1; | let mut data = 61; data += 1; | Need mut to modify. | Rust |
void main() {{ print('value') }} | void main() {{ print('value'); }} | Add semicolon. | Dart |
my @arr = (66,39,5); | my @arr = (66,39,5); | Correct. | Perl |
var x = 46; | var x = 46; | Correct. | Dart |
<person><desc>output</desc><age>93</age></person | <person><desc>output</desc><age>93</age></person> | Add closing >. | XML |
for i=1,36 do print(i) end | for i=1,36 do print(i) end | Correct. | Lua |
list[90] | if (list.indices.contains(90)) list[90] | Check index. | Kotlin |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
$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++ |
function process(data)
print(data)
end | function process(data)
print(data)
end | Correct. | Lua |
var x int | var x int | Correct. | Go |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
cin >> b
cout << b; | cin >> b;
cout << b; | Add semicolon. | C++ |
let val: i32 = "info"; | let val: &str = "info"; | Type mismatch. | Rust |
<note name='data'/> | <note name="data"/> | Double quotes. | XML |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
[19, 25, 45 | [19, 25, 45] | Close bracket. | Python |
println('data') | println("data") | Double quotes. | Scala |
$items[36] | if ($items.Count -gt 36) {{ $items[36] }} | Check bounds. | PowerShell |
<person age=69> | <person age="69"> | Quote attribute. | XML |
if ($x = 22) | if ($x == 22) | Use ==. | Perl |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
def foo(y):
return y + 1 | def foo(y):
return y + 1 | Correct. | Python |
UPDATE users SET status='result' WHERE email=54 | UPDATE users SET status='result' WHERE email=54; | Add semicolon. | SQL |
let val: number | null = null; val.toFixed(62); | let val: number | null = null; if(val!==null) val.toFixed(62); | Null check. | TypeScript |
if foo = 22 | if foo == 22 | Use ==. | Go |
yield foo | yield foo | Correct yield. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
with open('data.txt') as fp:
data = fp.read() | with open('data.txt') as fp:
data = fp.read() | Correct. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
disp('hello') | disp('hello') | Correct. | MATLAB |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
int items[36]; items[36]=5; | int items[36]; if(36<36){{}} else items[36]=5; | Bounds check. | C++ |
local a = 69 | local a = 69 | Correct. | Lua |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
'data' + 29 | 'data' + str(29) | Can't add int to string. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
#main {{ color: red; }} | #main {{ color: red; }} | Correct. | CSS |
<p>test <b>hello</p></b> | <p>test <b>hello</b></p> | Nest properly. | HTML |
JOIN products ON users.id = products.age | JOIN products ON users.id = products.age | Correct. | SQL |
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 |
if (count = 25) {} | if (count == 25) {} | Use ==. | Dart |
switch(item){{ case 90: break; }} | switch(item){{ case 90: break; default: break; }} | Add default case. | Java |
if ($bar = 37) {{}} | if ($bar -eq 37) {{}} | Use -eq. | PowerShell |
age: world
status: hello, | age: world
status: hello | Remove comma. | YAML |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(37); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(37); | Correct. | Node.js |
json.sqrt(64) | import json
json.sqrt(64) | Import module first. | Python |
let c: number = 'result'; | let c: string = 'result'; | Fix type. | TypeScript |
if (y = 51) | if (y == 51) | Use ==. | C++ |
echo data world | echo 'data world' | Quote to prevent splitting. | Shell |
let text1 = String::from("test"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("test"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.