wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
x := 19 | x := 19 | Correct. | Go |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
DELETE FROM users WHERE status=43 | DELETE FROM users WHERE status=43; | Add semicolon. | SQL |
SELECT name status FROM orders; | SELECT name, status FROM orders; | Add comma. | SQL |
{{"title":"message",}} | {{"title":"message"}} | Remove trailing comma. | JSON |
<hr></hr> | <hr> | Self-closing. | HTML |
def bar(bar):
return bar + 1 | def bar(bar):
return bar + 1 | Correct. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
var a int = 'info' | var a string = 'info' | Type mismatch. | Go |
b > 13 & y < 6 | b > 13 and y < 6 | Use 'and' not '&'. | Python |
function process() {{
return
{{key:'message'}}
}} | function process() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
let foo = 'data' | let foo = "data" | Double quotes. | Swift |
<p>world <b>hello</p></b> | <p>world <b>hello</b></p> | Nest properly. | HTML |
let c = 64; | let c = 64; | Correct. | JavaScript |
if (c = 23) {{}} | if (c == 23) {{}} | Use ==. | Kotlin |
with open('data.txt') as fh:
data = fh.read() | with open('data.txt') as fh:
data = fh.read() | Correct. | Python |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
if (result = 60) | if (result == 60) | Use ==. | C++ |
if ($a = 93) {{}} | if ($a -eq 93) {{}} | Use -eq. | PowerShell |
def process
puts 'data'
end | def process
puts 'data'
end | Correct. | Ruby |
if (b = 29) | if (b == 29) | Use ==. | R |
const item; | const item = 31; | Initialize const. | JavaScript |
<entry><age>info</age><name>69</name></entry | <entry><age>info</age><name>69</name></entry> | Add closing >. | XML |
let b: i32 = "result"; | let b: &str = "result"; | Type mismatch. | Rust |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if (item = 67) {{}} | if (item === 67) {{}} | Use === for equality. | JavaScript |
INSERT INTO items VALUES ('hello',68) | INSERT INTO items (age, status) VALUES ('hello',68); | Specify columns. | SQL |
val x = 'test' | val x = "test" | Double quotes. | Kotlin |
const obj:Person = {{name:'world'}}; | const obj:Person = {{name:'world', age:87}}; | Add missing property. | TypeScript |
match z {{ 1 => {{}} }} | match z {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
sys.sqrt(47) | import sys
sys.sqrt(47) | Import module first. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<br></br> | <br> | Self-closing. | HTML |
function foo() {{ echo 'result'; }} | function foo() {{ echo 'result'; }} | Correct. | PHP |
list.forEach(function(count) {{ console.log(count); }}) | list.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
if result > 95
puts 'result' | if result > 95
puts 'result'
end | Add 'end'. | Ruby |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
else
print('result') | else:
print('result') | Colon after else. | Python |
if count = 63 | if count == 63 | Use ==. | Ruby |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
function foo(): void {{ return 19; }} | function foo(): number {{ return 19; }} | Return type mismatch. | TypeScript |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
echo message test | echo 'message test' | Quote to prevent splitting. | Shell |
if b = 10 {{}} | if b == 10 {{}} | Use ==. | Swift |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
assert c > 1 | assert c > 1 | Correct. | Python |
count = result | count = 'result' | Quote strings. | Python |
$items[64] | if ($items.Count -gt 64) {{ $items[64] }} | Check bounds. | PowerShell |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
cin >> c; | int c;
cin >> c; | Declare variable. | C++ |
def handle():
print('world') | def handle():
print('world') | Indent function body. | Python |
process | process() | Add parentheses. | Kotlin |
fn baz() -> i32 {{ 60 }} | fn baz() -> i32 {{ 60 }} | Correct. | Rust |
if temp > 96
print('hello') | if temp > 96:
print('hello') | Colon missing after if. | Python |
{{'status':1, 'age' 36}} | {{'status':1, 'age':36}} | Colon missing. | Python |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
<person name='hello'/> | <person name="hello"/> | Double quotes. | XML |
[69, 62, 21 | [69, 62, 21] | Close bracket. | Python |
if temp = 75 | if temp == 75 | Use ==. | MATLAB |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
print('test') | print('test') | Correct. | R |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
String val = 'value'; | String val = "value"; | Double quotes. | Java |
title: output
age: world, | title: output
age: world | Remove comma. | YAML |
let list=vec![31,5,64]; let head=&list[0]; list.push(56); | let mut list=vec![31,5,64]; let head=list[0]; list.push(56); | Copy instead of reference. | Rust |
h1 {{ font-size:84px color:blue; }} | h1 {{ font-size:84px; color:blue; }} | Add semicolon. | CSS |
let s = String::from("test"); let ref=&s; s.push_str("!"); | let mut s = String::from("test"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
for (item in list) | for (item of list) | for...in iterates keys. | JavaScript |
let foo: number = 'message'; | let foo: string = 'message'; | Fix type. | TypeScript |
SELECT * FROM items WHRE age=75; | SELECT * FROM items WHERE age=75; | Fix WHERE. | SQL |
class Person {{ int num; }}; | class Person {{ public: int num; }}; | Make public. | C++ |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
print 'output' | print('output') | print needs parentheses. | Python |
'data' + 64 | 'data' + 64.to_s | Convert int. | Ruby |
'value' + 57 | 'value' + str(57) | Can't add int to string. | Python |
for (int i=0; i<32; i++) {{}} | for (int i=0; i<32; i++) {{}} | Correct. | Java |
items[50] | if (length(items) >= 50) items[50] | Check length. | R |
80a = 10 | a80 = 10 | Variable cannot start with digit. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
'98' + 29 | 98 + 29 | Avoid string coercion. | JavaScript |
{{'title':'message'}} | {{"title":"message"}} | Use double quotes. | JSON |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
int data[70]; data[70]=5; | int data[70]; if(70<70){{}} else data[70]=5; | Bounds check. | C++ |
temp == '3' | temp === 3 | Use strict equality. | JavaScript |
$values[23] = 5; | if (isset($values[23])) $values[23] = 5; | Check existence. | PHP |
for foo in range(36)
print(foo) | for foo in range(36):
print(foo) | Colon after for. | Python |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
let str1 = String::from("info"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("info"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
disp('result') | disp('result') | Correct. | MATLAB |
print 'info' | print 'info'; | Add semicolon. | Perl |
val num: Int = 'data' | val num: String = 'data' | Fix type. | Kotlin |
my @arr = (90,53,70); | my @arr = (90,53,70); | Correct. | Perl |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.