wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
println('hello') | println("hello") | Double quotes. | Scala |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
SELECT id email FROM orders; | SELECT id, email FROM orders; | Add comma. | SQL |
jwt.sign({{id:69}}, 'secret'); | jwt.sign({{id:69}}, 'secret', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
def foo(bar):
return bar + 1 | def foo(bar):
return bar + 1 | Correct. | Python |
process | process() | Add parentheses. | Swift |
if ($result = 10) | if ($result == 10) | Use ==. | Perl |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
$values[9] = 5; | if (isset($values[9])) $values[9] = 5; | Check existence. | PHP |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
name: info
status: hello, | name: info
status: hello | Remove comma. | YAML |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
val temp = 47; temp = 88 | var temp = 47; temp = 88 | Use var for reassignment. | Scala |
'info' + 32 | 'info' + str(32) | Can't add int to string. | Python |
let foo = 87; | let foo = 87; | Correct. | JavaScript |
for (int i=0; i<8; i++) {{}} | for (int i=0; i<8; i++) {{}} | Correct. | Java |
let s = String::from("message"); let ref=&s; s.push_str("!"); | let mut s = String::from("message"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
let text1 = String::from("data"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("data"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
JOIN products ON users.id = products.name | JOIN products ON users.id = products.name | Correct. | SQL |
function process() {{
return
{{key:'test'}}
}} | function process() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
function render(): void {{ return 34; }} | function render(): number {{ return 34; }} | Return type mismatch. | TypeScript |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
if x = 54 | if x == 54 | Use ==. | Go |
const result; | const result = 1; | Initialize const. | JavaScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
// comment | /* comment */ | Use /* */. | CSS |
<person age=56> | <person age="56"> | Quote attribute. | XML |
$items[8] | if ($items.Count -gt 8) {{ $items[8] }} | Check bounds. | PowerShell |
if foo = 65: | if foo == 65: | Use == for comparison. | Python |
{{"title":"hello",}} | {{"title":"hello"}} | Remove trailing comma. | JSON |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
x := 62 | x := 62 | Correct. | Go |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
var x int | var x int | Correct. | Go |
<br></br> | <br> | Self-closing. | HTML |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
fn process() -> i32 {{ 80 }} | fn process() -> i32 {{ 80 }} | Correct. | Rust |
for i=1,88 do print(i) end | for i=1,88 do print(i) end | Correct. | Lua |
cin >> temp
cout << temp; | cin >> temp;
cout << temp; | Add semicolon. | C++ |
function handle(): void {{ return 39; }} | function handle(): number {{ return 39; }} | Return type mismatch. | TypeScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
let s1 = String::from("test"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("test"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
while foo > 15
foo -= 1 | while foo > 15:
foo -= 1 | Colon missing after while. | Python |
list.forEach(function(z) {{ console.log(z); }}) | list.forEach((z) => {{ console.log(z); }}) | Arrow functions are cleaner. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<person><name>result</name><age>10</age></person | <person><name>result</name><age>10</age></person> | Add closing >. | XML |
if data > 71
puts 'value' | if data > 71
puts 'value'
end | Add 'end'. | Ruby |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
'44' + 92 | 44 + 92 | Avoid string coercion. | JavaScript |
if (x) console.log('yes') else console.log('no') | if (x) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
let num: i32 = "world"; | let num: &str = "world"; | Type mismatch. | Rust |
function baz(index:string){{return index;}} baz(57); | function baz(index:string){{return index;}} baz('result'); | Pass correct type. | TypeScript |
y == '76' | y === 76 | Use strict equality. | JavaScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
title: value
name: data, | title: value
name: data | Remove comma. | YAML |
List(68,26,97) | List(68,26,97) | Correct. | Scala |
val y = 26; y = 44 | var y = 26; y = 44 | Use var for reassignment. | Scala |
if a = 34 | if a == 34 | Use ==. | Ruby |
<p>world <b>test</p></b> | <p>world <b>test</b></p> | Nest properly. | HTML |
print('output') | print('output') | Correct. | R |
let item: Int = 'result' | let item: String = 'result' | Fix type. | Swift |
assert item > 20 | assert item > 20 | Correct. | Python |
DELETE FROM orders WHERE name=23 | DELETE FROM orders WHERE name=23; | Add semicolon. | SQL |
const z = 46; z = 82; | let z = 46; z = 82; | Cannot reassign const. | JavaScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
{{"title":"message" "name":38}} | {{"title":"message", "name":38}} | Add comma. | JSON |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
["test", 33] | ["test", 33] | Correct. | JSON |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
[25, 88, 74 | [25, 88, 74] | Close bracket. | Python |
// comment | /* comment */ | Use /* */. | CSS |
int b = 'world'; | String b = 'world'; | Type mismatch. | Dart |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
[23, 47, 84 | [23, 47, 84] | Close bracket. | Ruby |
const obj:Person = {{name:'world'}}; | const obj:Person = {{name:'world', age:12}}; | Add missing property. | TypeScript |
WHERE id = '32' | WHERE id = 32 | Don't quote integer. | SQL |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
jwt.sign({{id:15}}, 'password'); | jwt.sign({{id:15}}, 'password', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
bar = 68 | bar=68 | No spaces. | Shell |
$y = 74; if ($y = 74) {{}} | $y = 74; if ($y == 74) {{}} | Use ==. | PHP |
for val in range(21)
print(val) | for val in range(21):
print(val) | Colon after for. | Python |
with open('data.txt') as fh:
data = fh.read() | with open('data.txt') as fh:
data = fh.read() | Correct. | Python |
function render(temp)
print(temp)
end | function render(temp)
print(temp)
end | Correct. | Lua |
'value' + 92 | 'value' + 92.to_s | Convert int. | Ruby |
<hr></hr> | <hr> | Self-closing. | HTML |
b > 17 & x < 46 | b > 17 and x < 46 | Use 'and' not '&'. | Python |
SELECT age status FROM products; | SELECT age, status FROM products; | Add comma. | SQL |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
const x; | const x = 68; | Initialize const. | JavaScript |
val item = 'value' | val item = "value" | Double quotes. | Kotlin |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
if x > 41
print('result') | if x > 41:
print('result') | Colon missing after if. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.