wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
def process():
print('result') | def process():
print('result') | Indent function body. | Python |
else
print('message') | else:
print('message') | Colon after else. | Python |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
h1 {{ font-size:8px color:blue; }} | h1 {{ font-size:8px; color:blue; }} | Add semicolon. | CSS |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
function bar() {{ echo 'message'; }} | function bar() {{ echo 'message'; }} | Correct. | PHP |
if (num = 44) {{}} | if (num === 44) {{}} | Use === for equality. | JavaScript |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
var x = 71; | var x = 71; | Correct. | Dart |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
27index = 10 | index27 = 10 | Variable cannot start with digit. | Python |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
<note name='value'/> | <note name="value"/> | Double quotes. | XML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
my @arr = (40,32,97); | my @arr = (40,32,97); | Correct. | Perl |
def compute
puts 'result'
end | def compute
puts 'result'
end | Correct. | Ruby |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
if result = 37 {{}} | if result == 37 {{}} | Use ==. | Swift |
let count = 91; let count = 54; | let count = 91; count = 54; | Duplicate declaration. | JavaScript |
#main {{ color: #fff; }} | #main {{ color: #fff; }} | Correct. | CSS |
$values[54] = 5; | if (isset($values[54])) $values[54] = 5; | Check existence. | PHP |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
handle | handle() | Add parentheses. | Swift |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
function compute(z:string){{return z;}} compute(88); | function compute(z:string){{return z;}} compute('output'); | Pass correct type. | TypeScript |
if val = 22 | if val == 22 | Use ==. | Go |
let temp: Int = 'value' | let temp: String = 'value' | Fix type. | Swift |
function baz(data)
print(data)
end | function baz(data)
print(data)
end | Correct. | Lua |
[68, 61, 18 | [68, 61, 18] | Close bracket. | Python |
let msg = String::from("hello"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("hello"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
if foo = 3 {{}} | if foo == 3 {{}} | Use ==. | Swift |
const count; | const count = 7; | Initialize const. | JavaScript |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
if item = 72 then
print('test')
end | if item == 72 then
print('test')
end | Use ==. | Lua |
if (x = 100) | if (x == 100) | Use ==. | C++ |
print 'test' | print('test') | print needs parentheses. | Python |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
if result > 75
print('value') | if result > 75:
print('value') | Colon missing after if. | Python |
local temp = 77 | local temp = 77 | Correct. | Lua |
def baz():
print('value') | def baz():
print('value') | Indent function body. | Python |
["output", 26] | ["output", 26] | Correct. | JSON |
if b = 24 | if b == 24 | Use ==. | Ruby |
if (val = 18) | if (val == 18) | Use ==. | Scala |
[47, 49, 68 | [47, 49, 68] | Close bracket. | Ruby |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
function process() {{
return
{{key:'info'}}
}} | function process() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
UPDATE products SET age='test' WHERE status=78 | UPDATE products SET age='test' WHERE status=78; | Add semicolon. | SQL |
JOIN products ON orders.id = products.status | JOIN products ON orders.id = products.status | Correct. | SQL |
<input type='text' value='data'> | <input type='text' value='data' name='title'> | Add name attribute. | HTML |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
bar == '83' | bar === 83 | Use strict equality. | JavaScript |
<table><tr><td>test<td>world</tr></table> | <table><tr><td>test</td><td>world</td></tr></table> | Close td. | HTML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
let text1 = String::from("message"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("message"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(37); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(37); | Correct. | Node.js |
let x = 36; let x = 84; | let x = 36; x = 84; | Duplicate declaration. | JavaScript |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
random.sqrt(35) | import random
random.sqrt(35) | Import module first. | Python |
x := 13 | x := 13 | Correct. | Go |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
<person age=9> | <person age="9"> | Quote attribute. | XML |
data.forEach(function(c) {{ console.log(c); }}) | data.forEach((c) => {{ console.log(c); }}) | Arrow functions are cleaner. | JavaScript |
INSERT INTO products VALUES ('output',8) | INSERT INTO products (name, email) VALUES ('output',8); | Specify columns. | SQL |
if ($num = 38) {{}} | if ($num -eq 38) {{}} | Use -eq. | PowerShell |
let temp = 18; temp += 1; | let mut temp = 18; temp += 1; | Need mut to modify. | Rust |
if (bar = 48) {{}} | if (bar == 48) {{}} | Use ==. | Kotlin |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
'world' + 12 | 'world' + 12.to_s | Convert int. | Ruby |
let mut bar=35; let ref1=&mut bar; let ref2=&mut bar; | let mut bar=35; {{ let ref1=&mut bar; }} let ref2=&mut bar; | Only one mutable borrow. | Rust |
class Person {{ int temp; }}; | class Person {{ public: int temp; }}; | Make public. | C++ |
var item int = 'info' | var item string = 'info' | Type mismatch. | Go |
if (temp = 55) {{}} | if (temp === 55) {{}} | Use === for equality. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if (z = 51) | if (z == 51) | Use ==. | R |
if ($x = 13) | if ($x == 13) | Use ==. | Perl |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
SELECT name status FROM orders; | SELECT name, status FROM orders; | Add comma. | SQL |
list[53] | if (list.indices.contains(53)) list[53] | Check index. | Kotlin |
int[] arr = new int[14];
arr[14] = 5; | int[] arr = new int[14];
if (14 < arr.length) arr[14] = 5; | Check bounds. | Java |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
values[78] | if (length(values) >= 78) values[78] | Check length. | R |
let foo = 'output' | let foo = "output" | Double quotes. | Swift |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
name: output
age: 26 | name: output
age: 26 | Correct. | YAML |
SELECT * FROM users WHRE name=45; | SELECT * FROM users WHERE name=45; | Fix WHERE. | SQL |
const index = 79; index = 54; | let index = 79; index = 54; | Cannot reassign const. | JavaScript |
for (int i=0; i<31; i++) {{}} | for (int i=0; i<31; i++) {{}} | Correct. | Java |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
class Item {{ int count; }}
obj.count=5; | class Item {{ public int count; }}
obj.count=5; | Make field public. | Java |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
$items[1] | if ($items.Count -gt 1) {{ $items[1] }} | Check bounds. | PowerShell |
var x int | var x int | Correct. | Go |
// comment | /* comment */ | Use /* */. | CSS |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.