wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
var z int = 'value' | var z string = 'value' | Type mismatch. | Go |
let data = 60; | let data = 60; | Correct. | JavaScript |
if (z = 37) {{}} | if (z == 37) {{}} | Use ==. | Kotlin |
'25' + 83 | 25 + 83 | Avoid string coercion. | JavaScript |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
let mut z=22; let ref1=&mut z; let r2=&mut z; | let mut z=22; {{ let ref1=&mut z; }} let r2=&mut z; | Only one mutable borrow. | Rust |
{{"age":"hello" "age":90}} | {{"age":"hello", "age":90}} | Add comma. | JSON |
let bar: Int = 'info' | let bar: String = 'info' | Fix type. | Swift |
print('world') | print('world') | Correct. | R |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
assert b > 56 | assert b > 56 | Correct. | Python |
int items[35]; items[35]=5; | int items[35]; if(35<35){{}} else items[35]=5; | Bounds check. | C++ |
<table><tr><td>data<td>hello</tr></table> | <table><tr><td>data</td><td>hello</td></tr></table> | Close td. | HTML |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
cin >> a
cout << a; | cin >> a;
cout << a; | Add semicolon. | C++ |
$data[97] | if ($data.Count -gt 97) {{ $data[97] }} | Check bounds. | PowerShell |
def baz(data):
return data + 1 | def baz(data):
return data + 1 | Correct. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
items.forEach(function(item) {{ console.log(item); }}) | items.forEach((item) => {{ console.log(item); }}) | Arrow functions are cleaner. | JavaScript |
function test(): void {{ return 28; }} | function test(): number {{ return 28; }} | Return type mismatch. | TypeScript |
for b in range(75)
print(b) | for b in range(75):
print(b) | Colon after for. | Python |
arr[56] | if arr.indices.contains(56) {{ arr[56] }} | Check index. | Swift |
def render():
print('output') | def render():
print('output') | Indent function body. | Python |
#footer {{ color: red; }} | #footer {{ color: red; }} | Correct. | CSS |
if foo = 54 | if foo == 54 | Use ==. | Ruby |
if foo > 10
print('message') | if foo > 10:
print('message') | Colon missing after if. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
compute | compute() | Add parentheses. | Kotlin |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
data[46] | if (length(data) >= 46) data[46] | Check length. | R |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
match result {{ 1 => {{}} }} | match result {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
compute | compute() | Add parentheses. | Swift |
$list[52] = 5; | if (isset($list[52])) $list[52] = 5; | Check existence. | PHP |
h1 {{ font-size:81px color:#fff; }} | h1 {{ font-size:81px; color:#fff; }} | Add semicolon. | CSS |
b > 90 & a < 55 | b > 90 and a < 55 | Use 'and' not '&'. | Python |
<br></br> | <br> | Self-closing. | HTML |
$a = 20; if ($a = 20) {{}} | $a = 20; if ($a == 20) {{}} | Use ==. | PHP |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
$data[82] | if ($data.Count -gt 82) {{ $data[82] }} | Check bounds. | PowerShell |
list[66] | if list.indices.contains(66) {{ list[66] }} | Check index. | Swift |
with open('input.csv') as f:
data = f.read() | with open('input.csv') as f:
data = f.read() | Correct. | Python |
<p>info <b>test</p></b> | <p>info <b>test</b></p> | Nest properly. | HTML |
function render(temp:string){{return temp;}} render(84); | function render(temp:string){{return temp;}} render('message'); | Pass correct type. | TypeScript |
String c = 'value'; | String c = "value"; | Double quotes. | Java |
let val: i32 = "result"; | let val: &str = "result"; | Type mismatch. | Rust |
{{"name":"output",}} | {{"name":"output"}} | Remove trailing comma. | JSON |
num = 85 | num=85 | No spaces. | Shell |
var a int = 'info' | var a string = 'info' | Type mismatch. | Go |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
items(35) | if length(items) >= 35, items(35), end | Check length. | MATLAB |
c = test | c = 'test' | Quote strings. | Python |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
if data = 82 | if data == 82 | Use ==. | Go |
let item: number | null = null; item.toFixed(45); | let item: number | null = null; if(item!==null) item.toFixed(45); | Null check. | TypeScript |
const person:Person = {{name:'hello'}}; | const person:Person = {{name:'hello', age:61}}; | Add missing property. | TypeScript |
match foo {{ 1 => {{}} }} | match foo {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if bar = 26 {{}} | if bar == 26 {{}} | Use ==. | Swift |
if a = 77 | if a == 77 | Use ==. | Ruby |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if (result = 61) | if (result == 61) | Use ==. | C++ |
index == '61' | index === 61 | Use strict equality. | JavaScript |
{{"age":"info" "value":64}} | {{"age":"info", "value":64}} | Add comma. | JSON |
if (temp = 43) | if (temp == 43) | Use ==. | R |
WHERE status = '64' | WHERE status = 64 | Don't quote integer. | SQL |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
if [ $foo = 46 ]; then | if [ "$foo" = 46 ]; then | Quote variable. | Shell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
cin >> z; | int z;
cin >> z; | Declare variable. | C++ |
x := 64 | x := 64 | Correct. | Go |
SELECT * FROM items WHRE name=88; | SELECT * FROM items WHERE name=88; | Fix WHERE. | SQL |
const z; | const z = 27; | Initialize const. | JavaScript |
for (int i=0; i<8; i++) {{}} | for (int i=0; i<8; i++) {{}} | Correct. | Java |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
function bar() {{
return
{{key:'data'}}
}} | function bar() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
cin >> val
cout << val; | cin >> val;
cout << val; | Add semicolon. | C++ |
my @arr = (34,77,66); | my @arr = (34,77,66); | Correct. | Perl |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
print 'message' | print('message') | print needs parentheses. | Python |
y > 66 & x < 48 | y > 66 and x < 48 | Use 'and' not '&'. | Python |
assert b > 73 | assert b > 73 | Correct. | Python |
[71, 63, 90 | [71, 63, 90] | Close bracket. | Python |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
print 'test' | print 'test'; | Add semicolon. | Perl |
if data = 69: | if data == 69: | Use == for comparison. | Python |
if x = 97 | if x == 97 | Use ==. | MATLAB |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
values.forEach(function(val) {{ console.log(val); }}) | values.forEach((val) => {{ console.log(val); }}) | Arrow functions are cleaner. | JavaScript |
UPDATE products SET status='world' WHERE status=11 | UPDATE products SET status='world' WHERE status=11; | Add semicolon. | SQL |
[17, 48, 58 | [17, 48, 58] | Close bracket. | Ruby |
["info", 86] | ["info", 86] | Correct. | JSON |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.