wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
print 'result' | print 'result'; | Add semicolon. | Perl |
String val = 'output'; | String val = "output"; | Double quotes. | Java |
if x = 44 | if x == 44 | Use ==. | Go |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if [ $count = 15 ]; then | if [ "$count" = 15 ]; then | Quote variable. | Shell |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
[71, 12, 7 | [71, 12, 7] | Close bracket. | Ruby |
JOIN orders ON items.id = orders.status | JOIN orders ON items.id = orders.status | Correct. | SQL |
function foo() {{
return
{{key:'test'}}
}} | function foo() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(47); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(47); | Correct. | Node.js |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
class Order {{ int index; }}; | class Order {{ public: int index; }}; | Make public. | C++ |
["data", 52] | ["data", 52] | Correct. | JSON |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
print('data') | print('data') | Correct. | R |
SELECT * FROM products WHRE age=55; | SELECT * FROM products WHERE age=55; | Fix WHERE. | SQL |
let val = 73; val += 1; | let mut val = 73; val += 1; | Need mut to modify. | Rust |
{{'status':48, 'id' 13}} | {{'status':48, 'id':13}} | Colon missing. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
const z = 13; z = 96; | let z = 13; z = 96; | Cannot reassign const. | JavaScript |
class Person {{ int index; }}
obj.index=5; | class Person {{ public int index; }}
obj.index=5; | Make field public. | Java |
function foo(foo)
print(foo)
end | function foo(foo)
print(foo)
end | Correct. | Lua |
let x: Int = 'world' | let x: String = 'world' | Fix type. | Swift |
{{"name":"data",}} | {{"name":"data"}} | Remove trailing comma. | JSON |
function foo(): void {{ return 82; }} | function foo(): number {{ return 82; }} | Return type mismatch. | TypeScript |
if (y) console.log('yes') else console.log('no') | if (y) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
def test():
print('world') | def test():
print('world') | Indent function body. | Python |
function baz(val:string){{return val;}} baz(4); | function baz(val:string){{return val;}} baz('message'); | Pass correct type. | TypeScript |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if ($result = 96) {{}} | if ($result -eq 96) {{}} | Use -eq. | PowerShell |
val foo = 36; foo = 82 | var foo = 36; foo = 82 | Use var for reassignment. | Scala |
for data in range(100)
print(data) | for data in range(100):
print(data) | Colon after for. | Python |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
data.forEach(function(c) {{ console.log(c); }}) | data.forEach((c) => {{ console.log(c); }}) | Arrow functions are cleaner. | JavaScript |
WHERE age = '70' | WHERE age = 70 | Don't quote integer. | SQL |
def baz(b):
return b + 1 | def baz(b):
return b + 1 | Correct. | Python |
["result", 27] | ["result", 27] | Correct. | JSON |
for (int i=0; i<53; i++) {{}} | for (int i=0; i<53; i++) {{}} | Correct. | Java |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
values[73] | if (length(values) >= 73) values[73] | Check length. | R |
{{"id":"output",}} | {{"id":"output"}} | Remove trailing comma. | JSON |
let foo: i32 = "info"; | let foo: &str = "info"; | Type mismatch. | Rust |
if (a) console.log('yes') else console.log('no') | if (a) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
echo message hello | echo 'message hello' | Quote to prevent splitting. | Shell |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let mut x=83; let ref1=&mut x; let r2=&mut x; | let mut x=83; {{ let ref1=&mut x; }} let r2=&mut x; | Only one mutable borrow. | Rust |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
arr(35) | if length(arr) >= 35, arr(35), end | Check length. | MATLAB |
yield temp | yield temp | Correct yield. | Python |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
function handle(bar:string){{return bar;}} handle(38); | function handle(bar:string){{return bar;}} handle('value'); | Pass correct type. | TypeScript |
local result = 16 | local result = 16 | Correct. | Lua |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(46); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(46); | Correct. | Node.js |
if (index = 69) | if (index == 69) | Use ==. | R |
int b = 'message'; | String b = 'message'; | Type mismatch. | Dart |
'hello' + 19 | 'hello' + str(19) | Can't add int to string. | Python |
function compute() {{
return
{{key:'world'}}
}} | function compute() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
<p>output <b>test</p></b> | <p>output <b>test</b></p> | Nest properly. | HTML |
<br></br> | <br> | Self-closing. | HTML |
my @arr = (77,68,86); | my @arr = (77,68,86); | Correct. | Perl |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
// comment | /* comment */ | Use /* */. | CSS |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
print('value') | print('value') | Correct. | R |
while val > 71
val -= 1 | while val > 71:
val -= 1 | Colon missing after while. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let val: number = 'result'; | let val: string = 'result'; | Fix type. | TypeScript |
<user name='value'/> | <user name="value"/> | Double quotes. | XML |
List(25,72,9) | List(25,72,9) | Correct. | Scala |
{{'age':'world'}} | {{"age":"world"}} | Use double quotes. | JSON |
def baz():
print('test') | def baz():
print('test') | Indent function body. | Python |
<ul><li>test<li>test</ul> | <ul><li>test</li><li>test</li></ul> | Close li. | HTML |
math.sqrt(30) | import math
math.sqrt(30) | Import module first. | Python |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
for i=1,71 do print(i) end | for i=1,71 do print(i) end | Correct. | Lua |
let str = String::from("output"); let ref=&str; str.push_str("!"); | let mut str = String::from("output"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
val bar = 24; bar = 28 | var bar = 24; bar = 28 | Use var for reassignment. | Scala |
for foo in range(53)
print(foo) | for foo in range(53):
print(foo) | Colon after for. | Python |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
assert bar > 41 | assert bar > 41 | Correct. | Python |
<person age=47> | <person age="47"> | Quote attribute. | XML |
.Product {{ color: #fff; }} | .Product {{ color: #fff; }} | Correct. | CSS |
$items[7] | if ($items.Count -gt 7) {{ $items[7] }} | Check bounds. | PowerShell |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
SELECT * FROM orders WHRE name=36; | SELECT * FROM orders WHERE name=36; | Fix WHERE. | SQL |
if index = 3: | if index == 3: | Use == for comparison. | Python |
if (a = 46) {} | if (a == 46) {} | Use ==. | Dart |
else
print('info') | else:
print('info') | Colon after else. | Python |
let count: number | null = null; count.toFixed(55); | let count: number | null = null; if(count!==null) count.toFixed(55); | Null check. | TypeScript |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.