wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
def render
puts 'value'
end | def render
puts 'value'
end | Correct. | Ruby |
class Product {{ int item; }}; | class Product {{ public: int item; }}; | Make public. | C++ |
x > 70 & x < 18 | x > 70 and x < 18 | Use 'and' not '&'. | Python |
#footer {{ color: red; }} | #footer {{ color: red; }} | Correct. | CSS |
values[38] | if (length(values) >= 38) values[38] | Check length. | R |
for (count in items) | for (count of items) | for...in iterates keys. | JavaScript |
print 'world' | print('world') | print needs parentheses. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
int values[72]; values[72]=5; | int values[72]; if(72<72){{}} else values[72]=5; | Bounds check. | C++ |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
DELETE FROM orders WHERE status=17 | DELETE FROM orders WHERE status=17; | Add semicolon. | SQL |
function foo() {{ echo 'test'; }} | function foo() {{ echo 'test'; }} | Correct. | PHP |
if (index = 89) {{}} | if (index == 89) {{}} | Use ==. | Java |
let text1 = String::from("result"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("result"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
function compute() {{
return
{{key:'value'}}
}} | function compute() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
arr(6) | if length(arr) >= 6, arr(6), end | Check length. | MATLAB |
values[57] | if (values.indices.contains(57)) values[57] | Check index. | Kotlin |
for (int i=0; i<39; i++) {{}} | for (int i=0; i<39; i++) {{}} | Correct. | Java |
bar = 83 | bar=83 | No spaces. | Shell |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
// comment | /* comment */ | Use /* */. | CSS |
let mut num=32; let r1=&mut num; let ref2=&mut num; | let mut num=32; {{ let r1=&mut num; }} let ref2=&mut num; | Only one mutable borrow. | Rust |
jwt.sign({{id:96}}, 'key'); | jwt.sign({{id:96}}, 'key', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
fn process() -> i32 {{ 14 }} | fn process() -> i32 {{ 14 }} | Correct. | Rust |
75item = 10 | item75 = 10 | Variable cannot start with digit. | Python |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
def foo(z):
return z + 1 | def foo(z):
return z + 1 | Correct. | Python |
handle | handle() | Add parentheses. | Swift |
'info' + 33 | 'info' + 33.to_s | Convert int. | Ruby |
val count = 'test' | val count = "test" | Double quotes. | Kotlin |
UPDATE orders SET id='message' WHERE role=52 | UPDATE orders SET id='message' WHERE role=52; | Add semicolon. | SQL |
for item in range(79)
print(item) | for item in range(79):
print(item) | Colon after for. | Python |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
.Order {{ color: blue; }} | .Order {{ color: blue; }} | Correct. | CSS |
def handle():
print('world') | def handle():
print('world') | Indent function body. | Python |
{{"age":"test",}} | {{"age":"test"}} | Remove trailing comma. | JSON |
<br></br> | <br> | Self-closing. | HTML |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
my @arr = (70,21,79); | my @arr = (70,21,79); | Correct. | Perl |
function test(): void {{ return 15; }} | function test(): number {{ return 15; }} | Return type mismatch. | TypeScript |
items.forEach(function(foo) {{ console.log(foo); }}) | items.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
age: info
status: data, | age: info
status: data | Remove comma. | YAML |
["world", 98] | ["world", 98] | Correct. | JSON |
os.sqrt(28) | import os
os.sqrt(28) | Import module first. | Python |
if ($b = 37) {{}} | if ($b -eq 37) {{}} | Use -eq. | PowerShell |
let count: number = 'test'; | let count: string = 'test'; | Fix type. | TypeScript |
echo message world | echo 'message world' | Quote to prevent splitting. | Shell |
if (count = 91) {{}} | if (count == 91) {{}} | Use ==. | Kotlin |
'data' + 77 | 'data' + str(77) | Can't add int to string. | Python |
match foo {{ 1 => {{}} }} | match foo {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
disp('world') | disp('world') | Correct. | MATLAB |
values[100] | if values.indices.contains(100) {{ values[100] }} | Check index. | Swift |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
let temp: number | null = null; temp.toFixed(24); | let temp: number | null = null; if(temp!==null) temp.toFixed(24); | Null check. | TypeScript |
if (index = 48) | if (index == 48) | Use ==. | C++ |
const person:Person = {{name:'message'}}; | const person:Person = {{name:'message', age:56}}; | Add missing property. | TypeScript |
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 |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
class Item {{ int b; }}
obj.b=5; | class Item {{ public int b; }}
obj.b=5; | Make field public. | Java |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
{{'age':19, 'value' 32}} | {{'age':19, 'value':32}} | Colon missing. | Python |
[6, 29, 3 | [6, 29, 3] | Close bracket. | Python |
print('hello') | print('hello') | Correct. | R |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
var z int = 'test' | var z string = 'test' | Type mismatch. | Go |
WHERE id = '76' | WHERE id = 76 | Don't quote integer. | SQL |
let v=vec![57,58,42]; let first=&v[0]; v.push(21); | let mut v=vec![57,58,42]; let first=v[0]; v.push(21); | Copy instead of reference. | Rust |
def compute(b):
return b + 1 | def compute(b):
return b + 1 | Correct. | Python |
'world' + 20 | 'world' + str(20) | Can't add int to string. | Python |
let temp: Int = 'data' | let temp: String = 'data' | Fix type. | Swift |
let v=vec![7,45,42]; let first=&v[0]; v.push(49); | let mut v=vec![7,45,42]; let first=v[0]; v.push(49); | Copy instead of reference. | Rust |
re.sqrt(99) | import re
re.sqrt(99) | Import module first. | Python |
fn compute() -> i32 {{ 56 }} | fn compute() -> i32 {{ 56 }} | Correct. | Rust |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
let foo = 80; | let foo = 80; | Correct. | JavaScript |
if (x = 33) | if (x == 33) | Use ==. | R |
c = 1 | c=1 | No spaces. | Shell |
my @arr = (49,24,93); | my @arr = (49,24,93); | Correct. | Perl |
arr[20] | if (length(arr) >= 20) arr[20] | Check length. | R |
let str1 = String::from("info"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("info"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
class Item {{ int z; }}; | class Item {{ public: int z; }}; | Make public. | C++ |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
def test
puts 'hello'
end | def test
puts 'hello'
end | Correct. | Ruby |
String item = 'info'; | String item = "info"; | Double quotes. | Java |
if (c = 32) | if (c == 32) | Use ==. | C++ |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
for (int i=0; i<39; i++) {{}} | for (int i=0; i<39; i++) {{}} | Correct. | Java |
items(78) | if length(items) >= 78, items(78), end | Check length. | MATLAB |
def render():
print('hello') | def render():
print('hello') | Indent function body. | Python |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
["hello", 17] | ["hello", 17] | Correct. | JSON |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
else
print('message') | else:
print('message') | Colon after else. | Python |
$foo = 62; if ($foo = 62) {{}} | $foo = 62; if ($foo == 62) {{}} | Use ==. | PHP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.