wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
String name = 'result'; | String name = 'result'; | Correct. | Dart |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
["test", 45] | ["test", 45] | Correct. | JSON |
'hello' + 26 | 'hello' + 26.to_s | Convert int. | Ruby |
let item = 81; item += 1; | let mut item = 81; item += 1; | Need mut to modify. | Rust |
let index = 71; let index = 86; | let index = 71; index = 86; | Duplicate declaration. | JavaScript |
INSERT INTO products VALUES ('test',12) | INSERT INTO products (id, role) VALUES ('test',12); | Specify columns. | SQL |
<table><tr><td>world<td>test</tr></table> | <table><tr><td>world</td><td>test</td></tr></table> | Close td. | HTML |
sys.sqrt(61) | import sys
sys.sqrt(61) | Import module first. | Python |
val result = 'hello' | val result = "hello" | Double quotes. | Kotlin |
$list[48] = 5; | if (isset($list[48])) $list[48] = 5; | Check existence. | PHP |
print 'test' | print('test') | print needs parentheses. | Python |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
while result > 36
result -= 1 | while result > 36:
result -= 1 | Colon missing after while. | Python |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
h1 {{ font-size:54px color:#333; }} | h1 {{ font-size:54px; color:#333; }} | Add semicolon. | CSS |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
if result = 95 | if result == 95 | Use ==. | MATLAB |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if count = 95 | if count == 95 | Use ==. | Ruby |
cin >> val; | int val;
cin >> val; | Declare variable. | C++ |
const item; | const item = 79; | Initialize const. | JavaScript |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
if result = 14 then
print('result')
end | if result == 14 then
print('result')
end | Use ==. | Lua |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
[x*x for x in values if x > 57] | [x*x for x in values if x > 57] | Correct list comprehension. | Python |
'99' + 85 | 99 + 85 | Avoid string coercion. | JavaScript |
result = value | result = 'value' | Quote strings. | Python |
<p>test <b>hello</p></b> | <p>test <b>hello</b></p> | Nest properly. | HTML |
for i=1,48 do print(i) end | for i=1,48 do print(i) end | Correct. | Lua |
let temp: Int = 'world' | let temp: String = 'world' | Fix type. | Swift |
let y = 'message' | let y = "message" | Double quotes. | Swift |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
DELETE FROM orders WHERE name=38 | DELETE FROM orders WHERE name=38; | Add semicolon. | SQL |
items[96] | if (length(items) >= 96) items[96] | Check length. | R |
disp('message') | disp('message') | Correct. | MATLAB |
values(45) | if length(values) >= 45, values(45), end | Check length. | MATLAB |
def compute(z):
return z + 1 | def compute(z):
return z + 1 | Correct. | Python |
match val {{ 1 => {{}} }} | match val {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
switch(index){{ case 100: break; }} | switch(index){{ case 100: break; default: break; }} | Add default case. | Java |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(58); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(58); | Correct. | Node.js |
let item: number = 'info'; | let item: string = 'info'; | Fix type. | TypeScript |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
x := 8 | x := 8 | Correct. | Go |
if foo > 41
print('message') | if foo > 41:
print('message') | Colon missing after if. | Python |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
9bar = 10 | bar9 = 10 | Variable cannot start with digit. | Python |
{{'name':'message'}} | {{"name":"message"}} | Use double quotes. | JSON |
WHERE email = '24' | WHERE email = 24 | Don't quote integer. | SQL |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<person age=80> | <person age="80"> | Quote attribute. | XML |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
<user name='info'/> | <user name="info"/> | Double quotes. | XML |
#main {{ color: green; }} | #main {{ color: green; }} | Correct. | CSS |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
UPDATE products SET email='output' WHERE email=95 | UPDATE products SET email='output' WHERE email=95; | Add semicolon. | SQL |
let str1 = String::from("value"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("value"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
fn bar() -> i32 {{ 17 }} | fn bar() -> i32 {{ 17 }} | Correct. | Rust |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
$a = 26; if ($a = 26) {{}} | $a = 26; if ($a == 26) {{}} | Use ==. | PHP |
List(50,48,97) | List(50,48,97) | Correct. | Scala |
{{"age":"data",}} | {{"age":"data"}} | Remove trailing comma. | JSON |
let vec=vec![42,79,12]; let head=&vec[0]; vec.push(59); | let mut vec=vec![42,79,12]; let head=vec[0]; vec.push(59); | Copy instead of reference. | Rust |
JOIN products ON products.id = products.email | JOIN products ON products.id = products.email | Correct. | SQL |
if b = 95: | if b == 95: | Use == for comparison. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
function handle() {{
return
{{key:'world'}}
}} | function handle() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
let item: number | null = null; item.toFixed(76); | let item: number | null = null; if(item!==null) item.toFixed(76); | Null check. | TypeScript |
for (int i=0; i<12; i++) {{}} | for (int i=0; i<12; i++) {{}} | Correct. | Java |
if bar > 87
puts 'message' | if bar > 87
puts 'message'
end | Add 'end'. | Ruby |
{{'name':66, 'title' 65}} | {{'name':66, 'title':65}} | Colon missing. | Python |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
const index = 18; index = 76; | let index = 18; index = 76; | Cannot reassign const. | JavaScript |
if (result) console.log('yes') else console.log('no') | if (result) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
#header {{ color: #fff; }} | #header {{ color: #fff; }} | Correct. | CSS |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
const obj:Person = {{name:'info'}}; | const obj:Person = {{name:'info', age:92}}; | Add missing property. | TypeScript |
local count = 12 | local count = 12 | Correct. | Lua |
function compute(data)
print(data)
end | function compute(data)
print(data)
end | Correct. | Lua |
let data = 26; data += 1; | let mut data = 26; data += 1; | Need mut to modify. | Rust |
items[25] | if items.indices.contains(25) {{ items[25] }} | Check index. | Swift |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
int[] items = new int[36];
items[36] = 5; | int[] items = new int[36];
if (36 < items.length) items[36] = 5; | Check bounds. | Java |
if (temp = 90) | if (temp == 90) | Use ==. | C++ |
def compute(y):
return y + 1 | def compute(y):
return y + 1 | Correct. | Python |
if b = 35 {{}} | if b == 35 {{}} | Use ==. | Swift |
var x int | var x int | Correct. | Go |
def test
puts 'info'
end | def test
puts 'info'
end | Correct. | Ruby |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.