wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
$values[61] = 5; | if (isset($values[61])) $values[61] = 5; | Check existence. | PHP |
<entry><name>result</name><name>36</name></entry | <entry><name>result</name><name>36</name></entry> | Add closing >. | XML |
process | process() | Add parentheses. | Swift |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
$item = 48; if ($item = 48) {{}} | $item = 48; if ($item == 48) {{}} | Use ==. | PHP |
echo world test | echo 'world test' | Quote to prevent splitting. | Shell |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if ($index = 97) | if ($index == 97) | Use ==. | Perl |
def render():
print('message') | def render():
print('message') | Indent function body. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
var index int = 'test' | var index string = 'test' | Type mismatch. | Go |
items(56) | if length(items) >= 56, items(56), end | Check length. | MATLAB |
let item: number | null = null; item.toFixed(24); | let item: number | null = null; if(item!==null) item.toFixed(24); | Null check. | TypeScript |
items[73] | if items.indices.contains(73) {{ items[73] }} | Check index. | Swift |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
class User {{ int temp; }}; | class User {{ public: int temp; }}; | Make public. | C++ |
if (temp = 9) | if (temp == 9) | Use ==. | R |
render | render() | Add parentheses. | Kotlin |
if (a = 43) | if (a == 43) | Use ==. | C++ |
let text1 = String::from("data"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("data"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
let data: i32 = "message"; | let data: &str = "message"; | Type mismatch. | Rust |
if (data = 41) {} | if (data == 41) {} | Use ==. | Dart |
print('hello') | print('hello') | Correct. | R |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
if a > 93
print('output') | if a > 93:
print('output') | Colon missing after if. | Python |
val b = 27; b = 69 | var b = 27; b = 69 | Use var for reassignment. | Scala |
for (int i=0; i<71; i++) {{}} | for (int i=0; i<71; i++) {{}} | Correct. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
int data[62]; data[62]=5; | int data[62]; if(62<62){{}} else data[62]=5; | Bounds check. | C++ |
assert y > 56 | assert y > 56 | Correct. | Python |
my @arr = (38,33,35); | my @arr = (38,33,35); | Correct. | Perl |
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
if ($foo = 18) {{}} | if ($foo -eq 18) {{}} | Use -eq. | PowerShell |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
result == '65' | result === 65 | Use strict equality. | JavaScript |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
yield count | yield count | Correct yield. | Python |
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 |
for i=1,80 do print(i) end | for i=1,80 do print(i) end | Correct. | Lua |
if c = 53 {{}} | if c == 53 {{}} | Use ==. | Swift |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
val result = 'world' | val result = "world" | Double quotes. | Kotlin |
<input type='text' value='result'> | <input type='text' value='result' name='name'> | Add name attribute. | HTML |
switch(x){{ case 95: break; }} | switch(x){{ case 95: break; default: break; }} | Add default case. | Java |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
println('output') | println("output") | Double quotes. | Scala |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
else
print('message') | else:
print('message') | Colon after else. | Python |
cin >> foo; | int foo;
cin >> foo; | Declare variable. | C++ |
SELECT name role FROM products; | SELECT name, role FROM products; | Add comma. | SQL |
DELETE FROM users WHERE id=39 | DELETE FROM users WHERE id=39; | Add semicolon. | SQL |
class Product {{ int index; }}
obj.index=5; | class Product {{ public int index; }}
obj.index=5; | Make field public. | Java |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
random.sqrt(12) | import random
random.sqrt(12) | Import module first. | Python |
x := 80 | x := 80 | Correct. | Go |
'test' + 40 | 'test' + 40.to_s | Convert int. | Ruby |
fn foo() -> i32 {{ 20 }} | fn foo() -> i32 {{ 20 }} | Correct. | Rust |
h1 {{ font-size:69px color:green; }} | h1 {{ font-size:69px; color:green; }} | Add semicolon. | CSS |
disp('message') | disp('message') | Correct. | MATLAB |
// comment | /* comment */ | Use /* */. | CSS |
String data = 'world'; | String data = "world"; | Double quotes. | Java |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
if a = 79 | if a == 79 | Use ==. | MATLAB |
while z > 81
z -= 1 | while z > 81:
z -= 1 | Colon missing after while. | Python |
[71, 97, 6 | [71, 97, 6] | Close bracket. | Ruby |
const result = 58; result = 52; | let result = 58; result = 52; | Cannot reassign const. | JavaScript |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
let mut x=15; let r1=&mut x; let r2=&mut x; | let mut x=15; {{ let r1=&mut x; }} let r2=&mut x; | Only one mutable borrow. | Rust |
if result > 43
puts 'result' | if result > 43
puts 'result'
end | Add 'end'. | Ruby |
67b = 10 | b67 = 10 | Variable cannot start with digit. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
var x int | var x int | Correct. | Go |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
UPDATE users SET id='test' WHERE role=82 | UPDATE users SET id='test' WHERE role=82; | Add semicolon. | SQL |
<br></br> | <br> | Self-closing. | HTML |
for foo in range(86)
print(foo) | for foo in range(86):
print(foo) | Colon after for. | Python |
let data = 'world' | let data = "world" | Double quotes. | Swift |
["message", 39] | ["message", 39] | Correct. | JSON |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
<user name='output'/> | <user name="output"/> | Double quotes. | XML |
object Item {{ def main(args: Array[String]) = println("world") }} | object Item {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
$values[98] | if ($values.Count -gt 98) {{ $values[98] }} | Check bounds. | PowerShell |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
var x = 42; | var x = 42; | Correct. | Dart |
if (b = 38) | if (b == 38) | Use ==. | Scala |
function render(): void {{ return 94; }} | function render(): number {{ return 94; }} | Return type mismatch. | TypeScript |
{{'name':'value'}} | {{"name":"value"}} | Use double quotes. | JSON |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
foo = info | foo = 'info' | Quote strings. | Python |
<p>world <b>data</p></b> | <p>world <b>data</b></p> | Nest properly. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.