wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
def render():
print('value') | def render():
print('value') | Indent function body. | Python |
let str = String::from("test"); let ref=&str; str.push_str("!"); | let mut str = String::from("test"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
assert foo > 69 | assert foo > 69 | Correct. | Python |
if b = 71 | if b == 71 | Use ==. | MATLAB |
else
print('value') | else:
print('value') | Colon after else. | Python |
int y = 'test'; | String y = 'test'; | Type mismatch. | Dart |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
let temp: number = 'result'; | let temp: string = 'result'; | Fix type. | TypeScript |
for b in range(43)
print(b) | for b in range(43):
print(b) | Colon after for. | Python |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
json.sqrt(89) | import json
json.sqrt(89) | Import module first. | Python |
name: output
age: 38 | name: output
age: 38 | Correct. | YAML |
.User {{ color: red; }} | .User {{ color: red; }} | Correct. | CSS |
switch(a){{ case 79: break; }} | switch(a){{ case 79: break; default: break; }} | Add default case. | Java |
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 |
class Product {{ int x; }}; | class Product {{ public: int x; }}; | Make public. | C++ |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
id: result
status: data, | id: result
status: data | Remove comma. | YAML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
let temp = 65; | let temp = 65; | Correct. | JavaScript |
INSERT INTO items VALUES ('message',86) | INSERT INTO items (id, email) VALUES ('message',86); | Specify columns. | SQL |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
{{'id':'data'}} | {{"id":"data"}} | Use double quotes. | JSON |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
if (index = 72) {{}} | if (index === 72) {{}} | Use === for equality. | JavaScript |
if [ $num = 8 ]; then | if [ "$num" = 8 ]; then | Quote variable. | Shell |
'info' + 31 | 'info' + 31.to_s | Convert int. | Ruby |
function handle() {{ echo 'value'; }} | function handle() {{ echo 'value'; }} | Correct. | PHP |
if (z) console.log('yes') else console.log('no') | if (z) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
my @arr = (20,5,4); | my @arr = (20,5,4); | Correct. | Perl |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
$index = 6; if ($index = 6) {{}} | $index = 6; if ($index == 6) {{}} | Use ==. | PHP |
// comment | /* comment */ | Use /* */. | CSS |
<ul><li>world<li>test</ul> | <ul><li>world</li><li>test</li></ul> | Close li. | HTML |
JOIN products ON orders.id = products.status | JOIN products ON orders.id = products.status | Correct. | SQL |
print 'world' | print 'world'; | Add semicolon. | Perl |
{{"age":"value",}} | {{"age":"value"}} | Remove trailing comma. | JSON |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
[55, 14, 26 | [55, 14, 26] | Close bracket. | Python |
list[21] | if list.indices.contains(21) {{ list[21] }} | Check index. | Swift |
int items[57]; items[57]=5; | int items[57]; if(57<57){{}} else items[57]=5; | Bounds check. | C++ |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<p>value <b>world</p></b> | <p>value <b>world</b></p> | Nest properly. | HTML |
<entry name='value'/> | <entry name="value"/> | Double quotes. | XML |
if (x = 70) | if (x == 70) | Use ==. | Scala |
data = 73 | data=73 | No spaces. | Shell |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if index = 18 | if index == 18 | Use ==. | Go |
h1 {{ font-size:84px color:#fff; }} | h1 {{ font-size:84px; color:#fff; }} | Add semicolon. | CSS |
$data[38] | if ($data.Count -gt 38) {{ $data[38] }} | Check bounds. | PowerShell |
match y {{ 1 => {{}} }} | match y {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
arr[17] | if (length(arr) >= 17) arr[17] | Check length. | R |
yield c | yield c | Correct yield. | Python |
if (z) console.log('yes') else console.log('no') | if (z) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
INSERT INTO items VALUES ('message',46) | INSERT INTO items (name, role) VALUES ('message',46); | Specify columns. | SQL |
switch(data){{ case 45: break; }} | switch(data){{ case 45: break; default: break; }} | Add default case. | Java |
let num = 'hello' | let num = "hello" | Double quotes. | Swift |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
let list=vec![69,43,48]; let primary=&list[0]; list.push(82); | let mut list=vec![69,43,48]; let primary=list[0]; list.push(82); | Copy instead of reference. | Rust |
let result = 62; let result = 58; | let result = 62; result = 58; | Duplicate declaration. | JavaScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
let msg = String::from("message"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("message"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
function render(a)
print(a)
end | function render(a)
print(a)
end | Correct. | Lua |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
int a = 'message'; | String a = 'message'; | Type mismatch. | Dart |
yield item | yield item | Correct yield. | Python |
let temp: number = 'world'; | let temp: string = 'world'; | Fix type. | TypeScript |
// comment | /* comment */ | Use /* */. | CSS |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
age: world
status: hello, | age: world
status: hello | Remove comma. | YAML |
val item = 62; item = 53 | var item = 62; item = 53 | Use var for reassignment. | Scala |
[98, 3, 49 | [98, 3, 49] | Close bracket. | Python |
'value' + 79 | 'value' + str(79) | Can't add int to string. | Python |
temp = test | temp = 'test' | Quote strings. | Python |
const count; | const count = 86; | Initialize const. | JavaScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
list[41] | if list.indices.contains(41) {{ list[41] }} | Check index. | Swift |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
object Item {{ def main(args: Array[String]) = println("message") }} | object Item {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(13); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(13, () => console.log('listening')); | Add callback. | Node.js |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
89temp = 10 | temp89 = 10 | Variable cannot start with digit. | Python |
{{'id':'data'}} | {{"id":"data"}} | Use double quotes. | JSON |
data.forEach(function(y) {{ console.log(y); }}) | data.forEach((y) => {{ console.log(y); }}) | Arrow functions are cleaner. | JavaScript |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
var x int | var x int | Correct. | Go |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
let foo: number | null = null; foo.toFixed(52); | let foo: number | null = null; if(foo!==null) foo.toFixed(52); | Null check. | TypeScript |
var x = 99; | var x = 99; | Correct. | Dart |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.