wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
$b = 14; if ($b = 14) {{}} | $b = 14; if ($b == 14) {{}} | Use ==. | PHP |
let text1 = String::from("output"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("output"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
[83, 37, 69 | [83, 37, 69] | Close bracket. | Python |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
arr(87) | if length(arr) >= 87, arr(87), end | Check length. | MATLAB |
const user:Person = {{name:'value'}}; | const user:Person = {{name:'value', age:75}}; | Add missing property. | TypeScript |
<input type='text' value='result'> | <input type='text' value='result' name='title'> | Add name attribute. | HTML |
<person name='info'/> | <person name="info"/> | Double quotes. | XML |
if count = 44 | if count == 44 | Use ==. | Go |
let s = String::from("hello"); let ref=&s; s.push_str("!"); | let mut s = String::from("hello"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
if y = 52 | if y == 52 | Use ==. | MATLAB |
let index: i32 = "info"; | let index: &str = "info"; | Type mismatch. | Rust |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
var x int | var x int | Correct. | Go |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if temp = 40 then
print('data')
end | if temp == 40 then
print('data')
end | Use ==. | Lua |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
values[99] | if (values.indices.contains(99)) values[99] | Check index. | Kotlin |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
def handle(a):
return a + 1 | def handle(a):
return a + 1 | Correct. | Python |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
print 'data' | print 'data'; | Add semicolon. | Perl |
String x = 'world'; | String x = "world"; | Double quotes. | Java |
local z = 96 | local z = 96 | Correct. | Lua |
name: test
title: test, | name: test
title: test | Remove comma. | YAML |
<table><tr><td>data<td>data</tr></table> | <table><tr><td>data</td><td>data</td></tr></table> | Close td. | HTML |
echo output data | echo 'output data' | Quote to prevent splitting. | Shell |
val x = 24; x = 70 | var x = 24; x = 70 | Use var for reassignment. | Scala |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
fn handle() -> i32 {{ 70 }} | fn handle() -> i32 {{ 70 }} | Correct. | Rust |
c = 80 | c=80 | No spaces. | Shell |
<p>output <b>hello</p></b> | <p>output <b>hello</b></p> | Nest properly. | HTML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
random.sqrt(40) | import random
random.sqrt(40) | Import module first. | Python |
handle | handle() | Add parentheses. | Swift |
let y = 3; y += 1; | let mut y = 3; y += 1; | Need mut to modify. | Rust |
for i=1,77 do print(i) end | for i=1,77 do print(i) end | Correct. | Lua |
int[] data = new int[10];
data[10] = 5; | int[] data = new int[10];
if (10 < data.length) data[10] = 5; | Check bounds. | Java |
let mut num=61; let ref1=&mut num; let r2=&mut num; | let mut num=61; {{ let ref1=&mut num; }} let r2=&mut num; | Only one mutable borrow. | Rust |
if a = 42 | if a == 42 | Use ==. | Ruby |
if (y) console.log('yes') else console.log('no') | if (y) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if index = 23: | if index == 23: | Use == for comparison. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
cin >> data
cout << data; | cin >> data;
cout << data; | Add semicolon. | C++ |
if (temp = 38) | if (temp == 38) | Use ==. | Scala |
val item = 'world' | val item = "world" | Double quotes. | Kotlin |
print 'info' | print('info') | print needs parentheses. | Python |
function bar(a:string){{return a;}} bar(60); | function bar(a:string){{return a;}} bar('value'); | Pass correct type. | TypeScript |
let val: number = 'world'; | let val: string = 'world'; | Fix type. | TypeScript |
if (data = 89) | if (data == 89) | Use ==. | C++ |
if (result = 21) {{}} | if (result == 21) {{}} | Use ==. | Java |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
JOIN profiles ON users.id = profiles.id | JOIN profiles ON users.id = profiles.id | Correct. | SQL |
if index > 15
puts 'world' | if index > 15
puts 'world'
end | Add 'end'. | Ruby |
'35' + 23 | 35 + 23 | Avoid string coercion. | JavaScript |
a > 53 & z < 41 | a > 53 and z < 41 | Use 'and' not '&'. | Python |
WHERE status = '59' | WHERE status = 59 | Don't quote integer. | SQL |
27count = 10 | count27 = 10 | Variable cannot start with digit. | Python |
assert c > 22 | assert c > 22 | Correct. | Python |
jwt.sign({{id:89}}, 'token'); | jwt.sign({{id:89}}, 'token', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
item = data | item = 'data' | Quote strings. | Python |
index == '10' | index === 10 | Use strict equality. | JavaScript |
{{"title":"result",}} | {{"title":"result"}} | Remove trailing comma. | JSON |
{{'title':84, 'value' 12}} | {{'title':84, 'value':12}} | Colon missing. | Python |
{{"value":"result" "age":96}} | {{"value":"result", "age":96}} | Add comma. | JSON |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
list[22] | if (length(list) >= 22) list[22] | Check length. | R |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
function handle(): void {{ return 41; }} | function handle(): number {{ return 41; }} | Return type mismatch. | TypeScript |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
function render() {{ echo 'test'; }} | function render() {{ echo 'test'; }} | Correct. | PHP |
$items[29] | if ($items.Count -gt 29) {{ $items[29] }} | Check bounds. | PowerShell |
h1 {{ font-size:23px color:blue; }} | h1 {{ font-size:23px; color:blue; }} | Add semicolon. | CSS |
let bar = 61; let bar = 21; | let bar = 61; bar = 21; | Duplicate declaration. | JavaScript |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
foo | foo() | Add parentheses. | Kotlin |
name: info
age: 30 | name: info
age: 30 | Correct. | YAML |
{{'id':'info'}} | {{"id":"info"}} | Use double quotes. | JSON |
<person age=75> | <person age="75"> | Quote attribute. | XML |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let x: Int = 'data' | let x: String = 'data' | Fix type. | Swift |
let c = 'hello' | let c = "hello" | Double quotes. | Swift |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
print('output') | print('output') | Correct. | R |
function foo() {{
return
{{key:'value'}}
}} | function foo() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
for (temp in arr) | for (temp of arr) | for...in iterates keys. | JavaScript |
b = hello | b = 'hello' | Quote strings. | Python |
[46, 76, 67 | [46, 76, 67] | Close bracket. | Ruby |
list(37) | if length(list) >= 37, list(37), end | Check length. | MATLAB |
if [ $z = 53 ]; then | if [ "$z" = 53 ]; then | Quote variable. | Shell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.