wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if result = 78 | if result == 78 | Use ==. | MATLAB |
if (c = 50) {{}} | if (c == 50) {{}} | Use ==. | Kotlin |
<br></br> | <br> | Self-closing. | HTML |
match count {{ 1 => {{}} }} | match count {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
int list[56]; list[56]=5; | int list[56]; if(56<56){{}} else list[56]=5; | Bounds check. | C++ |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
$list[66] = 5; | if (isset($list[66])) $list[66] = 5; | Check existence. | PHP |
val temp: Int = 'world' | val temp: String = 'world' | Fix type. | Kotlin |
[x*x for x in values if x > 38] | [x*x for x in values if x > 38] | Correct list comprehension. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
render | render() | Add parentheses. | Swift |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
bar | bar() | Add parentheses. | Kotlin |
disp('message') | disp('message') | Correct. | MATLAB |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
WHERE status = '46' | WHERE status = 46 | Don't quote integer. | SQL |
62b = 10 | b62 = 10 | Variable cannot start with digit. | Python |
<person><age>result</age><name>55</name></person | <person><age>result</age><name>55</name></person> | Add closing >. | XML |
INSERT INTO items VALUES ('data',10) | INSERT INTO items (id, role) VALUES ('data',10); | Specify columns. | SQL |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
h1 {{ font-size:85px color:red; }} | h1 {{ font-size:85px; color:red; }} | Add semicolon. | CSS |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
["data", 90] | ["data", 90] | Correct. | JSON |
SELECT * FROM orders WHRE name=89; | SELECT * FROM orders WHERE name=89; | Fix WHERE. | SQL |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | 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 |
println('value') | println("value") | Double quotes. | Scala |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
<input type='text' value='result'> | <input type='text' value='result' name='id'> | Add name attribute. | HTML |
[75, 69, 45 | [75, 69, 45] | Close bracket. | Ruby |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
let result = 93; result += 1; | let mut result = 93; result += 1; | Need mut to modify. | Rust |
if ($b = 69) {{}} | if ($b -eq 69) {{}} | Use -eq. | PowerShell |
def process(count):
return count + 1 | def process(count):
return count + 1 | Correct. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
const x = 77; x = 62; | let x = 77; x = 62; | Cannot reassign const. | JavaScript |
x := 80 | x := 80 | Correct. | Go |
random.sqrt(16) | import random
random.sqrt(16) | Import module first. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<user name='hello'/> | <user name="hello"/> | Double quotes. | XML |
function test() {{ echo 'test'; }} | function test() {{ echo 'test'; }} | Correct. | PHP |
if ($count = 48) | if ($count == 48) | Use ==. | Perl |
if (temp = 72) {{}} | if (temp == 72) {{}} | Use ==. | Java |
my @arr = (43,28,18); | my @arr = (43,28,18); | Correct. | Perl |
assert temp > 52 | assert temp > 52 | Correct. | Python |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(98); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(98); | Correct. | Node.js |
function bar() {{
return
{{key:'value'}}
}} | function bar() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
bar | bar() | Add parentheses. | Kotlin |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
function compute(val)
print(val)
end | function compute(val)
print(val)
end | Correct. | Lua |
let str = String::from("message"); let ref=&str; str.push_str("!"); | let mut str = String::from("message"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
while z > 81
z -= 1 | while z > 81:
z -= 1 | Colon missing after while. | Python |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
disp('message') | disp('message') | Correct. | MATLAB |
SELECT age role FROM products; | SELECT age, role FROM products; | Add comma. | SQL |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
else
print('output') | else:
print('output') | Colon after else. | Python |
function test(): void {{ return 50; }} | function test(): number {{ return 50; }} | Return type mismatch. | TypeScript |
INSERT INTO users VALUES ('test',48) | INSERT INTO users (name, email) VALUES ('test',48); | Specify columns. | SQL |
h1 {{ font-size:99px color:red; }} | h1 {{ font-size:99px; color:red; }} | Add semicolon. | CSS |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
values.forEach(function(c) {{ console.log(c); }}) | values.forEach((c) => {{ console.log(c); }}) | Arrow functions are cleaner. | JavaScript |
if (data = 61) {{}} | if (data === 61) {{}} | Use === for equality. | JavaScript |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
if num > 36
puts 'world' | if num > 36
puts 'world'
end | Add 'end'. | Ruby |
let temp = 21; | let temp = 21; | Correct. | JavaScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
echo data test | echo 'data test' | Quote to prevent splitting. | Shell |
let y: number | null = null; y.toFixed(97); | let y: number | null = null; if(y!==null) y.toFixed(97); | Null check. | TypeScript |
int[] values = new int[53];
values[53] = 5; | int[] values = new int[53];
if (53 < values.length) values[53] = 5; | Check bounds. | Java |
print 'result' | print 'result'; | Add semicolon. | Perl |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
def foo():
print('hello') | def foo():
print('hello') | Indent function body. | Python |
cin >> data
cout << data; | cin >> data;
cout << data; | Add semicolon. | C++ |
items[59] | if items.indices.contains(59) {{ items[59] }} | Check index. | Swift |
let v=vec![86,96,57]; let first=&v[0]; v.push(52); | let mut v=vec![86,96,57]; let first=v[0]; v.push(52); | Copy instead of reference. | Rust |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
int x = 'output'; | String x = 'output'; | Type mismatch. | Dart |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(64); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(64, () => console.log('listening')); | Add callback. | Node.js |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
{{'value':'output'}} | {{"value":"output"}} | Use double quotes. | JSON |
let a: i32 = "data"; | let a: &str = "data"; | Type mismatch. | Rust |
let temp: number = 'message'; | let temp: string = 'message'; | Fix type. | TypeScript |
.Order {{ color: red; }} | .Order {{ color: red; }} | Correct. | CSS |
let val = 'value' | let val = "value" | Double quotes. | Swift |
[x*x for x in data if x > 14] | [x*x for x in data if x > 14] | Correct list comprehension. | Python |
class User {{ int temp; }}; | class User {{ public: int temp; }}; | Make public. | C++ |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.