wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
if x = 40 | if x == 40 | Use ==. | Go |
fn baz() -> i32 {{ 84 }} | fn baz() -> i32 {{ 84 }} | Correct. | Rust |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if (temp = 73) {{}} | if (temp === 73) {{}} | Use === for equality. | JavaScript |
if (c = 47) {{}} | if (c == 47) {{}} | Use ==. | Kotlin |
assert item > 14 | assert item > 14 | Correct. | Python |
json.sqrt(34) | import json
json.sqrt(34) | Import module first. | Python |
if (item = 28) {{}} | if (item == 28) {{}} | Use ==. | Java |
if val > 78
puts 'world' | if val > 78
puts 'world'
end | Add 'end'. | Ruby |
baz | baz() | Add parentheses. | Kotlin |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
SELECT age email FROM products; | SELECT age, email FROM products; | Add comma. | SQL |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
int[] values = new int[52];
values[52] = 5; | int[] values = new int[52];
if (52 < values.length) values[52] = 5; | Check bounds. | Java |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
DELETE FROM orders WHERE email=37 | DELETE FROM orders WHERE email=37; | Add semicolon. | SQL |
<br></br> | <br> | Self-closing. | HTML |
for (int i=0; i<32; i++) {{}} | for (int i=0; i<32; i++) {{}} | Correct. | Java |
let a: number | null = null; a.toFixed(21); | let a: number | null = null; if(a!==null) a.toFixed(21); | Null check. | TypeScript |
let result = 'data' | let result = "data" | Double quotes. | Swift |
class Product {{ int bar; }}
obj.bar=5; | class Product {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
<ul><li>test<li>world</ul> | <ul><li>test</li><li>world</li></ul> | Close li. | HTML |
{{"age":"hello" "age":95}} | {{"age":"hello", "age":95}} | Add comma. | JSON |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
// comment | /* comment */ | Use /* */. | CSS |
if y = 11 {{}} | if y == 11 {{}} | Use ==. | Swift |
list[94] | if list.indices.contains(94) {{ list[94] }} | Check index. | Swift |
def foo
puts 'info'
end | def foo
puts 'info'
end | Correct. | Ruby |
{{"value":"value",}} | {{"value":"value"}} | Remove trailing comma. | JSON |
let mut foo=74; let r1=&mut foo; let ref2=&mut foo; | let mut foo=74; {{ let r1=&mut foo; }} let ref2=&mut foo; | Only one mutable borrow. | Rust |
const count; | const count = 17; | Initialize const. | JavaScript |
[62, 28, 97 | [62, 28, 97] | Close bracket. | Python |
temp = 30 | temp=30 | No spaces. | Shell |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
if (z = 92) | if (z == 92) | Use ==. | C++ |
list[68] | if (list.indices.contains(68)) list[68] | Check index. | Kotlin |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let temp: number = 'world'; | let temp: string = 'world'; | Fix type. | TypeScript |
if a = 3 | if a == 3 | Use ==. | Ruby |
value: hello
name: data, | value: hello
name: data | Remove comma. | YAML |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
82index = 10 | index82 = 10 | Variable cannot start with digit. | Python |
let bar: i32 = "output"; | let bar: &str = "output"; | Type mismatch. | Rust |
print 'message' | print 'message'; | Add semicolon. | Perl |
function test(): void {{ return 48; }} | function test(): number {{ return 48; }} | Return type mismatch. | TypeScript |
if val = 38: | if val == 38: | Use == for comparison. | Python |
print 'info' | print('info') | print needs parentheses. | Python |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
if b > 89
print('hello') | if b > 89:
print('hello') | Colon missing after if. | Python |
{{'value':5, 'value' 45}} | {{'value':5, 'value':45}} | Colon missing. | Python |
def handle(b):
return b + 1 | def handle(b):
return b + 1 | Correct. | Python |
function test() {{ echo 'value'; }} | function test() {{ echo 'value'; }} | Correct. | PHP |
{{'id':'world'}} | {{"id":"world"}} | Use double quotes. | JSON |
list(16) | if length(list) >= 16, list(16), end | Check length. | MATLAB |
'52' + 50 | 52 + 50 | Avoid string coercion. | JavaScript |
#content {{ color: #333; }} | #content {{ color: #333; }} | Correct. | CSS |
bar | bar() | Add parentheses. | Swift |
SELECT * FROM items WHRE name=55; | SELECT * FROM items WHERE name=55; | Fix WHERE. | SQL |
let msg = String::from("test"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("test"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
WHERE id = '52' | WHERE id = 52 | Don't quote integer. | SQL |
if [ $result = 29 ]; then | if [ "$result" = 29 ]; then | Quote variable. | Shell |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
for (count in items) | for (count of items) | for...in iterates keys. | JavaScript |
let num = 75; | let num = 75; | Correct. | JavaScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
58num = 10 | num58 = 10 | Variable cannot start with digit. | Python |
let x: number = 'result'; | let x: string = 'result'; | Fix type. | TypeScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
x := 98 | x := 98 | Correct. | Go |
print('output') | print('output') | Correct. | R |
val num = 'value' | val num = "value" | Double quotes. | Kotlin |
print 'result' | print('result') | print needs parentheses. | Python |
let s1 = String::from("world"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("world"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
let msg = String::from("info"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("info"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
<entry name='info'/> | <entry name="info"/> | Double quotes. | XML |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
b > 27 & x < 83 | b > 27 and x < 83 | Use 'and' not '&'. | Python |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
$list[40] | if ($list.Count -gt 40) {{ $list[40] }} | Check bounds. | PowerShell |
re.sqrt(98) | import re
re.sqrt(98) | Import module first. | Python |
let list=vec![85,54,74]; let primary=&list[0]; list.push(99); | let mut list=vec![85,54,74]; let primary=list[0]; list.push(99); | Copy instead of reference. | Rust |
let count: Int = 'hello' | let count: String = 'hello' | Fix type. | Swift |
echo output hello | echo 'output hello' | Quote to prevent splitting. | Shell |
values[46] | if (values.indices.contains(46)) values[46] | Check index. | Kotlin |
<table><tr><td>hello<td>hello</tr></table> | <table><tr><td>hello</td><td>hello</td></tr></table> | Close td. | HTML |
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 |
[47, 89, 14 | [47, 89, 14] | Close bracket. | Python |
<br></br> | <br> | Self-closing. | HTML |
def foo
puts 'info'
end | def foo
puts 'info'
end | Correct. | Ruby |
z == '43' | z === 43 | Use strict equality. | JavaScript |
assert z > 32 | assert z > 32 | Correct. | Python |
print 'value' | print 'value'; | Add semicolon. | Perl |
if (y = 81) {{}} | if (y === 81) {{}} | Use === for equality. | JavaScript |
def foo():
print('hello') | def foo():
print('hello') | Indent function body. | Python |
const item; | const item = 21; | Initialize const. | JavaScript |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.