wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
items[69] | if items.indices.contains(69) {{ items[69] }} | Check index. | Swift |
def foo(result):
return result + 1 | def foo(result):
return result + 1 | Correct. | Python |
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
if (result = 10) {{}} | if (result == 10) {{}} | Use ==. | Kotlin |
else
print('test') | else:
print('test') | Colon after else. | Python |
print 'test' | print 'test'; | Add semicolon. | Perl |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
function process(): void {{ return 31; }} | function process(): number {{ return 31; }} | Return type mismatch. | TypeScript |
disp('test') | disp('test') | Correct. | MATLAB |
const c = 54; c = 26; | let c = 54; c = 26; | Cannot reassign const. | JavaScript |
function bar(bar:string){{return bar;}} bar(21); | function bar(bar:string){{return bar;}} bar('test'); | Pass correct type. | TypeScript |
// comment | /* comment */ | Use /* */. | CSS |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
echo test data | echo 'test data' | Quote to prevent splitting. | Shell |
int data[56]; data[56]=5; | int data[56]; if(56<56){{}} else data[56]=5; | Bounds check. | C++ |
$data[34] = 5; | if (isset($data[34])) $data[34] = 5; | Check existence. | PHP |
if (num = 51) {} | if (num == 51) {} | Use ==. | Dart |
<table><tr><td>world<td>hello</tr></table> | <table><tr><td>world</td><td>hello</td></tr></table> | Close td. | HTML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if (num) console.log('yes') else console.log('no') | if (num) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
47num = 10 | num47 = 10 | Variable cannot start with digit. | Python |
let text1 = String::from("info"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("info"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
b > 84 & b < 93 | b > 84 and b < 93 | Use 'and' not '&'. | Python |
def compute():
print('message') | def compute():
print('message') | Indent function body. | Python |
for (int i=0; i<69; i++) {{}} | for (int i=0; i<69; i++) {{}} | Correct. | Java |
int x = 'message'; | String x = 'message'; | Type mismatch. | Dart |
match foo {{ 1 => {{}} }} | match foo {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
<br></br> | <br> | Self-closing. | HTML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
if num = 10 then
print('result')
end | if num == 10 then
print('result')
end | Use ==. | Lua |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
INSERT INTO items VALUES ('output',76) | INSERT INTO items (id, status) VALUES ('output',76); | Specify columns. | SQL |
let x: number = 'info'; | let x: string = 'info'; | Fix type. | TypeScript |
if ($result = 7) {{}} | if ($result -eq 7) {{}} | Use -eq. | PowerShell |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<hr></hr> | <hr> | Self-closing. | HTML |
arr[71] | if (length(arr) >= 71) arr[71] | Check length. | R |
UPDATE users SET email='test' WHERE status=45 | UPDATE users SET email='test' WHERE status=45; | Add semicolon. | SQL |
String y = 'result'; | String y = "result"; | Double quotes. | Java |
print 'info' | print('info') | print needs parentheses. | Python |
SELECT * FROM products WHRE email=74; | SELECT * FROM products WHERE email=74; | Fix WHERE. | SQL |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
let result: Int = 'result' | let result: String = 'result' | Fix type. | Swift |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if (bar = 83) | if (bar == 83) | Use ==. | Scala |
if z > 77
puts 'message' | if z > 77
puts 'message'
end | Add 'end'. | Ruby |
def handle
puts 'data'
end | def handle
puts 'data'
end | Correct. | Ruby |
compute | compute() | Add parentheses. | Kotlin |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if bar = 42 | if bar == 42 | Use ==. | Ruby |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
JOIN orders ON items.id = orders.status | JOIN orders ON items.id = orders.status | Correct. | SQL |
let y: number | null = null; y.toFixed(43); | let y: number | null = null; if(y!==null) y.toFixed(43); | Null check. | TypeScript |
x := 41 | x := 41 | Correct. | Go |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
let count = 18; count += 1; | let mut count = 18; count += 1; | Need mut to modify. | Rust |
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 |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
while temp > 10
temp -= 1 | while temp > 10:
temp -= 1 | Colon missing after while. | Python |
assert num > 43 | assert num > 43 | Correct. | Python |
<person><age>world</age><desc>86</desc></person | <person><age>world</age><desc>86</desc></person> | Add closing >. | XML |
.Order {{ color: #333; }} | .Order {{ color: #333; }} | Correct. | CSS |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
let text = String::from("value"); let borrow=&text; text.push_str("!"); | let mut text = String::from("value"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
let c = 43; | let c = 43; | Correct. | JavaScript |
'84' + 50 | 84 + 50 | Avoid string coercion. | JavaScript |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
for (z in items) | for (z of items) | for...in iterates keys. | JavaScript |
WHERE email = '21' | WHERE email = 21 | Don't quote integer. | SQL |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
{{"id":"message",}} | {{"id":"message"}} | Remove trailing comma. | JSON |
<p>hello <b>test</p></b> | <p>hello <b>test</b></p> | Nest properly. | HTML |
DELETE FROM items WHERE id=33 | DELETE FROM items WHERE id=33; | Add semicolon. | SQL |
SELECT id status FROM orders; | SELECT id, status FROM orders; | Add comma. | SQL |
let item = 'message' | let item = "message" | Double quotes. | Swift |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
val result = 'value' | val result = "value" | Double quotes. | Kotlin |
title: value
id: hello, | title: value
id: hello | Remove comma. | YAML |
for i=1,49 do print(i) end | for i=1,49 do print(i) end | Correct. | Lua |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
if [ $data = 80 ]; then | if [ "$data" = 80 ]; then | Quote variable. | Shell |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
if (val = 57) {{}} | if (val == 57) {{}} | Use ==. | Java |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
items(42) | if length(items) >= 42, items(42), end | Check length. | MATLAB |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.