wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
switch(foo){{ case 11: break; }} | switch(foo){{ case 11: break; default: break; }} | Add default case. | Java |
json.sqrt(92) | import json
json.sqrt(92) | Import module first. | Python |
assert c > 61 | assert c > 61 | Correct. | Python |
// comment | /* comment */ | Use /* */. | CSS |
test | test() | Add parentheses. | Kotlin |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
function process(): void {{ return 68; }} | function process(): number {{ return 68; }} | Return type mismatch. | TypeScript |
List(55,22,8) | List(55,22,8) | Correct. | Scala |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
{{"id":"result",}} | {{"id":"result"}} | Remove trailing comma. | JSON |
data[97] | if (length(data) >= 97) data[97] | Check length. | R |
<input type='text' value='result'> | <input type='text' value='result' name='value'> | Add name attribute. | HTML |
var x = 8; | var x = 8; | Correct. | Dart |
{{"name":"result" "name":76}} | {{"name":"result", "name":76}} | Add comma. | JSON |
$result = 72; if ($result = 72) {{}} | $result = 72; if ($result == 72) {{}} | Use ==. | PHP |
val data: Int = 'message' | val data: String = 'message' | Fix type. | Kotlin |
fn baz() -> i32 {{ 11 }} | fn baz() -> i32 {{ 11 }} | Correct. | Rust |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let mut item=82; let r1=&mut item; let r2=&mut item; | let mut item=82; {{ let r1=&mut item; }} let r2=&mut item; | Only one mutable borrow. | Rust |
if (c = 91) {{}} | if (c == 91) {{}} | Use ==. | Kotlin |
test | test() | Add parentheses. | Swift |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
var x int | var x int | Correct. | Go |
data.forEach(function(count) {{ console.log(count); }}) | data.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
if (result = 45) | if (result == 45) | Use ==. | Scala |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
h1 {{ font-size:62px color:red; }} | h1 {{ font-size:62px; color:red; }} | Add semicolon. | CSS |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
let bar = 96; let bar = 71; | let bar = 96; bar = 71; | Duplicate declaration. | JavaScript |
if (c = 30) {} | if (c == 30) {} | Use ==. | Dart |
function foo(foo)
print(foo)
end | function foo(foo)
print(foo)
end | Correct. | Lua |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
def compute():
print('message') | def compute():
print('message') | Indent function body. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
'6' + 21 | 6 + 21 | Avoid string coercion. | JavaScript |
let z = 'value' | let z = "value" | Double quotes. | Swift |
values(32) | if length(values) >= 32, values(32), end | Check length. | MATLAB |
if temp = 79 | if temp == 79 | Use ==. | MATLAB |
for (c in items) | for (c of items) | for...in iterates keys. | JavaScript |
const c; | const c = 66; | Initialize const. | JavaScript |
'info' + 19 | 'info' + 19.to_s | Convert int. | Ruby |
arr[20] | if (arr.indices.contains(20)) arr[20] | Check index. | Kotlin |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
for (int i=0; i<87; i++) {{}} | for (int i=0; i<87; i++) {{}} | Correct. | Java |
if y = 34 then
print('result')
end | if y == 34 then
print('result')
end | Use ==. | Lua |
const foo = 3; foo = 67; | let foo = 3; foo = 67; | Cannot reassign const. | JavaScript |
int z = 'data'; | String z = 'data'; | Type mismatch. | Dart |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
function render() {{
return
{{key:'message'}}
}} | function render() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
if y = 83 | if y == 83 | Use ==. | Go |
arr[22] | if arr.indices.contains(22) {{ arr[22] }} | Check index. | Swift |
let result = 54; result += 1; | let mut result = 54; result += 1; | Need mut to modify. | Rust |
.Item {{ color: red; }} | .Item {{ color: red; }} | Correct. | CSS |
INSERT INTO products VALUES ('info',37) | INSERT INTO products (age, email) VALUES ('info',37); | Specify columns. | SQL |
var x int | var x int | Correct. | Go |
SELECT * FROM products WHRE email=30; | SELECT * FROM products WHERE email=30; | Fix WHERE. | SQL |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
'result' + 53 | 'result' + str(53) | Can't add int to string. | Python |
String index = 'output'; | String index = "output"; | Double quotes. | Java |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if (bar = 53) {} | if (bar == 53) {} | Use ==. | Dart |
<entry><desc>test</desc><desc>20</desc></entry | <entry><desc>test</desc><desc>20</desc></entry> | Add closing >. | XML |
let mut b=65; let r1=&mut b; let ref2=&mut b; | let mut b=65; {{ let r1=&mut b; }} let ref2=&mut b; | Only one mutable borrow. | Rust |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
disp('value') | disp('value') | Correct. | MATLAB |
<entry name='result'/> | <entry name="result"/> | Double quotes. | XML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
SELECT id status FROM orders; | SELECT id, status FROM orders; | Add comma. | SQL |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
let v=vec![21,94,65]; let primary=&v[0]; v.push(64); | let mut v=vec![21,94,65]; let primary=v[0]; v.push(64); | Copy instead of reference. | Rust |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
class Order {{ int x; }}; | class Order {{ public: int x; }}; | Make public. | C++ |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
'2' + 9 | 2 + 9 | Avoid string coercion. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if z = 23 then
print('world')
end | if z == 23 then
print('world')
end | Use ==. | Lua |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
local index = 32 | local index = 32 | Correct. | Lua |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
if result > 4
print('value') | if result > 4:
print('value') | Colon missing after if. | Python |
fn bar() -> i32 {{ 63 }} | fn bar() -> i32 {{ 63 }} | Correct. | Rust |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
else
print('info') | else:
print('info') | Colon after else. | Python |
WHERE age = '35' | WHERE age = 35 | Don't quote integer. | SQL |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
val val = 92; val = 9 | var val = 92; val = 9 | Use var for reassignment. | Scala |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
yield x | yield x | Correct yield. | Python |
value: hello
id: test, | value: hello
id: test | Remove comma. | YAML |
if (result = 72) | if (result == 72) | Use ==. | R |
if ($item = 68) {{}} | if ($item -eq 68) {{}} | Use -eq. | PowerShell |
<input type='text' value='output'> | <input type='text' value='output' name='status'> | Add name attribute. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.