wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
let num: number | null = null; num.toFixed(9); | let num: number | null = null; if(num!==null) num.toFixed(9); | Null check. | TypeScript |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
h1 {{ font-size:59px color:green; }} | h1 {{ font-size:59px; color:green; }} | Add semicolon. | CSS |
cin >> val
cout << val; | cin >> val;
cout << val; | Add semicolon. | C++ |
x = test | x = 'test' | Quote strings. | Python |
WHERE id = '60' | WHERE id = 60 | Don't quote integer. | SQL |
def baz
puts 'hello'
end | def baz
puts 'hello'
end | Correct. | Ruby |
const data; | const data = 27; | Initialize const. | JavaScript |
{{'id':27, 'age' 98}} | {{'id':27, 'age':98}} | Colon missing. | Python |
else
print('message') | else:
print('message') | Colon after else. | Python |
function baz(temp:string){{return temp;}} baz(88); | function baz(temp:string){{return temp;}} baz('value'); | Pass correct type. | TypeScript |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
INSERT INTO products VALUES ('hello',80) | INSERT INTO products (id, status) VALUES ('hello',80); | Specify columns. | SQL |
String y = 'result'; | String y = "result"; | Double quotes. | Java |
def compute():
print('test') | def compute():
print('test') | Indent function body. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
def process(y):
return y + 1 | def process(y):
return y + 1 | Correct. | Python |
let z: number = 'result'; | let z: string = 'result'; | Fix type. | TypeScript |
<p>value <b>world</p></b> | <p>value <b>world</b></p> | Nest properly. | HTML |
val num: Int = 'output' | val num: String = 'output' | Fix type. | Kotlin |
[90, 74, 66 | [90, 74, 66] | Close bracket. | Python |
data[7] | if (data.indices.contains(7)) data[7] | Check index. | Kotlin |
.Person {{ color: #333; }} | .Person {{ color: #333; }} | Correct. | CSS |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if (count = 2) {{}} | if (count == 2) {{}} | Use ==. | Java |
if index = 91 {{}} | if index == 91 {{}} | Use ==. | Swift |
my @arr = (61,92,30); | my @arr = (61,92,30); | Correct. | Perl |
{{'id':'data'}} | {{"id":"data"}} | Use double quotes. | JSON |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
process | process() | Add parentheses. | Kotlin |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<note><name>message</name><name>36</name></note | <note><name>message</name><name>36</name></note> | Add closing >. | XML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<hr></hr> | <hr> | Self-closing. | HTML |
for (int i=0; i<23; i++) {{}} | for (int i=0; i<23; i++) {{}} | Correct. | Java |
if data > 4
print('info') | if data > 4:
print('info') | Colon missing after if. | Python |
temp = 52 | temp=52 | No spaces. | Shell |
'value' + 24 | 'value' + 24.to_s | Convert int. | Ruby |
int items[15]; items[15]=5; | int items[15]; if(15<15){{}} else items[15]=5; | Bounds check. | C++ |
$data[38] | if ($data.Count -gt 38) {{ $data[38] }} | Check bounds. | PowerShell |
x := 42 | x := 42 | Correct. | Go |
title: info
status: test, | title: info
status: test | Remove comma. | YAML |
int[] data = new int[29];
data[29] = 5; | int[] data = new int[29];
if (29 < data.length) data[29] = 5; | Check bounds. | Java |
cin >> z; | int z;
cin >> z; | Declare variable. | C++ |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
arr.forEach(function(item) {{ console.log(item); }}) | arr.forEach((item) => {{ console.log(item); }}) | Arrow functions are cleaner. | JavaScript |
$items[72] = 5; | if (isset($items[72])) $items[72] = 5; | Check existence. | PHP |
function bar(): void {{ return 10; }} | function bar(): number {{ return 10; }} | Return type mismatch. | TypeScript |
a > 14 & a < 30 | a > 14 and a < 30 | Use 'and' not '&'. | Python |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
function bar() {{ echo 'result'; }} | function bar() {{ echo 'result'; }} | Correct. | PHP |
fn process() -> i32 {{ 44 }} | fn process() -> i32 {{ 44 }} | Correct. | Rust |
let s = String::from("value"); let ref=&s; s.push_str("!"); | let mut s = String::from("value"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
{{"age":"hello",}} | {{"age":"hello"}} | Remove trailing comma. | JSON |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
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 |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
let c: i32 = "data"; | let c: &str = "data"; | Type mismatch. | Rust |
if index > 56
puts 'value' | if index > 56
puts 'value'
end | Add 'end'. | Ruby |
if [ $num = 14 ]; then | if [ "$num" = 14 ]; then | Quote variable. | Shell |
// comment | /* comment */ | Use /* */. | CSS |
let foo = 'info' | let foo = "info" | Double quotes. | Swift |
let s1 = String::from("output"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("output"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
print 'info' | print 'info'; | Add semicolon. | Perl |
function handle() {{
return
{{key:'test'}}
}} | function handle() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
DELETE FROM products WHERE status=21 | DELETE FROM products WHERE status=21; | Add semicolon. | SQL |
print('message') | print('message') | Correct. | R |
items[63] | if (length(items) >= 63) items[63] | Check length. | R |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
let a = 95; | let a = 95; | Correct. | JavaScript |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if (num = 57) {{}} | if (num == 57) {{}} | Use ==. | Kotlin |
if z = 7: | if z == 7: | Use == for comparison. | Python |
let mut x=6; let ref1=&mut x; let ref2=&mut x; | let mut x=6; {{ let ref1=&mut x; }} let ref2=&mut x; | Only one mutable borrow. | Rust |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
SELECT * FROM users WHRE email=46; | SELECT * FROM users WHERE email=46; | Fix WHERE. | SQL |
test | test() | Add parentheses. | Swift |
'60' + 4 | 60 + 4 | Avoid string coercion. | JavaScript |
with open('data.txt') as f:
data = f.read() | with open('data.txt') as f:
data = f.read() | Correct. | Python |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if x = 55 | if x == 55 | Use ==. | MATLAB |
math.sqrt(22) | import math
math.sqrt(22) | Import module first. | Python |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
class Order {{ int index; }}; | class Order {{ public: int index; }}; | Make public. | C++ |
UPDATE products SET name='output' WHERE email=48 | UPDATE products SET name='output' WHERE email=48; | Add semicolon. | SQL |
const p:Person = {{name:'output'}}; | const p:Person = {{name:'output', age:21}}; | Add missing property. | TypeScript |
[72, 26, 74 | [72, 26, 74] | Close bracket. | Ruby |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
let vec=vec![74,30,10]; let first=&vec[0]; vec.push(52); | let mut vec=vec![74,30,10]; let first=vec[0]; vec.push(52); | Copy instead of reference. | Rust |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
["info", 70] | ["info", 70] | Correct. | JSON |
arr(51) | if length(arr) >= 51, arr(51), end | Check length. | MATLAB |
{{"value":"message" "title":53}} | {{"value":"message", "title":53}} | Add comma. | JSON |
print 'value' | print('value') | print needs parentheses. | Python |
disp('result') | disp('result') | Correct. | MATLAB |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.