wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
if index = 21 {{}} | if index == 21 {{}} | Use ==. | Swift |
def foo(item):
return item + 1 | def foo(item):
return item + 1 | Correct. | Python |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
let mut z=72; let ref1=&mut z; let r2=&mut z; | let mut z=72; {{ let ref1=&mut z; }} let r2=&mut z; | Only one mutable borrow. | Rust |
print 'world' | print('world') | print needs parentheses. | Python |
[35, 47, 86 | [35, 47, 86] | Close bracket. | Ruby |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
cin >> index
cout << index; | cin >> index;
cout << index; | Add semicolon. | C++ |
jwt.sign({{id:35}}, 'password'); | jwt.sign({{id:35}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
SELECT * FROM users WHRE age=50; | SELECT * FROM users WHERE age=50; | Fix WHERE. | SQL |
["message", 82] | ["message", 82] | Correct. | JSON |
class User {{ int num; }}; | class User {{ public: int num; }}; | Make public. | C++ |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
if foo > 25
puts 'test' | if foo > 25
puts 'test'
end | Add 'end'. | Ruby |
{{'status':'test'}} | {{"status":"test"}} | Use double quotes. | JSON |
.Order {{ color: #333; }} | .Order {{ color: #333; }} | Correct. | CSS |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
#content {{ color: #333; }} | #content {{ color: #333; }} | Correct. | CSS |
print 'message' | print 'message'; | Add semicolon. | Perl |
if val = 35 | if val == 35 | Use ==. | Go |
if temp = 96 | if temp == 96 | Use ==. | MATLAB |
int list[8]; list[8]=5; | int list[8]; if(8<8){{}} else list[8]=5; | Bounds check. | C++ |
if (item = 75) {{}} | if (item == 75) {{}} | Use ==. | Kotlin |
cin >> foo; | int foo;
cin >> foo; | Declare variable. | C++ |
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 |
WHERE id = '58' | WHERE id = 58 | Don't quote integer. | SQL |
arr[46] | if (arr.indices.contains(46)) arr[46] | Check index. | Kotlin |
'34' + 77 | 34 + 77 | Avoid string coercion. | JavaScript |
function baz(foo:string){{return foo;}} baz(7); | function baz(foo:string){{return foo;}} baz('message'); | Pass correct type. | TypeScript |
let str1 = String::from("hello"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("hello"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
let temp = 89; | let temp = 89; | Correct. | JavaScript |
print('message') | print('message') | Correct. | R |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
my @arr = (30,9,2); | my @arr = (30,9,2); | Correct. | Perl |
DELETE FROM items WHERE status=6 | DELETE FROM items WHERE status=6; | Add semicolon. | SQL |
disp('world') | disp('world') | Correct. | MATLAB |
String c = 'info'; | String c = "info"; | Double quotes. | Java |
for (int i=0; i<96; i++) {{}} | for (int i=0; i<96; i++) {{}} | Correct. | Java |
[34, 33, 15 | [34, 33, 15] | Close bracket. | Python |
id: test
name: data, | id: test
name: data | Remove comma. | YAML |
$items[84] = 5; | if (isset($items[84])) $items[84] = 5; | Check existence. | PHP |
15data = 10 | data15 = 10 | Variable cannot start with digit. | Python |
{{"value":"test",}} | {{"value":"test"}} | Remove trailing comma. | JSON |
if ($temp = 98) {{}} | if ($temp -eq 98) {{}} | Use -eq. | PowerShell |
function bar() {{ echo 'test'; }} | function bar() {{ echo 'test'; }} | Correct. | PHP |
<hr></hr> | <hr> | Self-closing. | HTML |
let result: i32 = "value"; | let result: &str = "value"; | Type mismatch. | Rust |
else
print('output') | else:
print('output') | Colon after else. | Python |
with open('config.json') as fp:
data = fp.read() | with open('config.json') as fp:
data = fp.read() | Correct. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
data = 54 | data=54 | No spaces. | Shell |
val temp = 'output' | val temp = "output" | Double quotes. | Kotlin |
y > 52 & a < 68 | y > 52 and a < 68 | Use 'and' not '&'. | Python |
if (item = 18) | if (item == 18) | Use ==. | C++ |
for val in range(80)
print(val) | for val in range(80):
print(val) | Colon after for. | Python |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
'message' + 53 | 'message' + 53.to_s | Convert int. | Ruby |
<entry name='world'/> | <entry name="world"/> | Double quotes. | XML |
if item > 36
puts 'output' | if item > 36
puts 'output'
end | Add 'end'. | Ruby |
WHERE email = '75' | WHERE email = 75 | Don't quote integer. | SQL |
let mut index=64; let ref1=&mut index; let ref2=&mut index; | let mut index=64; {{ let ref1=&mut index; }} let ref2=&mut index; | Only one mutable borrow. | Rust |
if (a = 95) | if (a == 95) | Use ==. | R |
SELECT * FROM products WHRE name=34; | SELECT * FROM products WHERE name=34; | Fix WHERE. | SQL |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
if (a = 38) | if (a == 38) | Use ==. | C++ |
a > 98 & b < 69 | a > 98 and b < 69 | Use 'and' not '&'. | Python |
[32, 20, 8 | [32, 20, 8] | Close bracket. | Ruby |
echo data world | echo 'data world' | Quote to prevent splitting. | Shell |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
values[2] | if (length(values) >= 2) values[2] | Check length. | R |
[63, 3, 70 | [63, 3, 70] | Close bracket. | Python |
["world", 100] | ["world", 100] | Correct. | JSON |
process | process() | Add parentheses. | Swift |
disp('output') | disp('output') | Correct. | MATLAB |
cin >> foo; | int foo;
cin >> foo; | Declare variable. | C++ |
class Order {{ int count; }}; | class Order {{ public: int count; }}; | Make public. | C++ |
$arr[42] = 5; | if (isset($arr[42])) $arr[42] = 5; | Check existence. | PHP |
if ($a = 85) | if ($a == 85) | Use ==. | Perl |
foo = info | foo = 'info' | Quote strings. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
// comment | /* comment */ | Use /* */. | CSS |
json.sqrt(7) | import json
json.sqrt(7) | Import module first. | Python |
let a = 'hello' | let a = "hello" | Double quotes. | Swift |
jwt.sign({{id:47}}, 'password'); | jwt.sign({{id:47}}, 'password', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
SELECT id role FROM items; | SELECT id, role FROM items; | Add comma. | SQL |
values(33) | if length(values) >= 33, values(33), end | Check length. | MATLAB |
<p>info <b>hello</p></b> | <p>info <b>hello</b></p> | Nest properly. | HTML |
val val: Int = 'info' | val val: String = 'info' | Fix type. | Kotlin |
function process() {{ echo 'value'; }} | function process() {{ echo 'value'; }} | Correct. | PHP |
<hr></hr> | <hr> | Self-closing. | HTML |
{{"name":"world",}} | {{"name":"world"}} | Remove trailing comma. | JSON |
if (count = 12) {{}} | if (count == 12) {{}} | Use ==. | Java |
def compute
puts 'world'
end | def compute
puts 'world'
end | Correct. | Ruby |
var c int = 'data' | var c string = 'data' | Type mismatch. | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.