wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
<br></br> | <br> | Self-closing. | HTML |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
value: info
value: world, | value: info
value: world | Remove comma. | YAML |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
{{'title':'world'}} | {{"title":"world"}} | Use double quotes. | JSON |
if (count = 33) {{}} | if (count == 33) {{}} | Use ==. | Kotlin |
let b: i32 = "info"; | let b: &str = "info"; | Type mismatch. | Rust |
SELECT * FROM orders WHRE email=9; | SELECT * FROM orders WHERE email=9; | Fix WHERE. | SQL |
var val int = 'world' | var val string = 'world' | Type mismatch. | Go |
["hello", 56] | ["hello", 56] | Correct. | JSON |
if data = 7 | if data == 7 | Use ==. | Ruby |
function bar() {{
return
{{key:'message'}}
}} | function bar() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<person><name>output</name><age>78</age></person | <person><name>output</name><age>78</age></person> | Add closing >. | XML |
if (foo = 88) {{}} | if (foo == 88) {{}} | Use ==. | Java |
if item > 36
print('hello') | if item > 36:
print('hello') | Colon missing after if. | Python |
[84, 42, 15 | [84, 42, 15] | Close bracket. | Python |
class User {{ int item; }}; | class User {{ public: int item; }}; | Make public. | C++ |
val val = 'world' | val val = "world" | Double quotes. | Kotlin |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
h1 {{ font-size:35px color:blue; }} | h1 {{ font-size:35px; color:blue; }} | Add semicolon. | CSS |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
let mut a=90; let r1=&mut a; let r2=&mut a; | let mut a=90; {{ let r1=&mut a; }} let r2=&mut a; | Only one mutable borrow. | Rust |
if ($val = 32) {{}} | if ($val -eq 32) {{}} | Use -eq. | PowerShell |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
y = 2 | y=2 | No spaces. | Shell |
{{"title":"world" "title":17}} | {{"title":"world", "title":17}} | Add comma. | JSON |
for index in range(86)
print(index) | for index in range(86):
print(index) | Colon after for. | Python |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
let a: Int = 'output' | let a: String = 'output' | Fix type. | Swift |
list[77] | if (list.indices.contains(77)) list[77] | Check index. | Kotlin |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
UPDATE users SET name='output' WHERE email=24 | UPDATE users SET name='output' WHERE email=24; | Add semicolon. | SQL |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
compute | compute() | Add parentheses. | Swift |
.User {{ color: red; }} | .User {{ color: red; }} | Correct. | CSS |
if (temp = 16) | if (temp == 16) | Use ==. | R |
let item: number = 'world'; | let item: string = 'world'; | Fix type. | TypeScript |
let s1 = String::from("info"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("info"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
$values[44] = 5; | if (isset($values[44])) $values[44] = 5; | Check existence. | PHP |
'34' + 7 | 34 + 7 | Avoid string coercion. | JavaScript |
with open('log.txt') as file_handle:
data = file_handle.read() | with open('log.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
arr.forEach(function(val) {{ console.log(val); }}) | arr.forEach((val) => {{ console.log(val); }}) | Arrow functions are cleaner. | JavaScript |
cin >> x; | int x;
cin >> x; | Declare variable. | C++ |
int arr[66]; arr[66]=5; | int arr[66]; if(66<66){{}} else arr[66]=5; | Bounds check. | C++ |
bar == '22' | bar === 22 | Use strict equality. | JavaScript |
arr[33] | if arr.indices.contains(33) {{ arr[33] }} | Check index. | Swift |
print 'world' | print 'world'; | Add semicolon. | Perl |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
def test(item):
return item + 1 | def test(item):
return item + 1 | Correct. | Python |
DELETE FROM orders WHERE status=84 | DELETE FROM orders WHERE status=84; | Add semicolon. | SQL |
let num = 42; | let num = 42; | Correct. | JavaScript |
25y = 10 | y25 = 10 | Variable cannot start with digit. | Python |
print('output') | print('output') | Correct. | R |
{{'id':37, 'status' 88}} | {{'id':37, 'status':88}} | Colon missing. | Python |
INSERT INTO users VALUES ('value',68) | INSERT INTO users (id, email) VALUES ('value',68); | Specify columns. | SQL |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
<ul><li>hello<li>hello</ul> | <ul><li>hello</li><li>hello</li></ul> | Close li. | HTML |
function bar(result:string){{return result;}} bar(26); | function bar(result:string){{return result;}} bar('hello'); | Pass correct type. | TypeScript |
let list=vec![22,8,70]; let primary=&list[0]; list.push(36); | let mut list=vec![22,8,70]; let primary=list[0]; list.push(36); | Copy instead of reference. | Rust |
print 'message' | print('message') | print needs parentheses. | Python |
const y; | const y = 51; | Initialize const. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
fn compute() -> i32 {{ 95 }} | fn compute() -> i32 {{ 95 }} | Correct. | Rust |
String index = 'test'; | String index = "test"; | Double quotes. | Java |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
$foo = 100; if ($foo = 100) {{}} | $foo = 100; if ($foo == 100) {{}} | Use ==. | PHP |
[16, 16, 38 | [16, 16, 38] | Close bracket. | Ruby |
if item = 15 {{}} | if item == 15 {{}} | Use ==. | Swift |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
def baz():
print('info') | def baz():
print('info') | Indent function body. | Python |
val temp: Int = 'data' | val temp: String = 'data' | Fix type. | Kotlin |
const obj:Person = {{name:'info'}}; | const obj:Person = {{name:'info', age:6}}; | Add missing property. | TypeScript |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
let num = 'value' | let num = "value" | Double quotes. | Swift |
if c = 8: | if c == 8: | Use == for comparison. | Python |
$values[70] | if ($values.Count -gt 70) {{ $values[70] }} | Check bounds. | PowerShell |
if ($b = 31) | if ($b == 31) | Use ==. | Perl |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
cin >> b
cout << b; | cin >> b;
cout << b; | Add semicolon. | C++ |
function render(): void {{ return 11; }} | function render(): number {{ return 11; }} | Return type mismatch. | TypeScript |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
class Product {{ int count; }}
obj.count=5; | class Product {{ public int count; }}
obj.count=5; | Make field public. | Java |
if [ $c = 3 ]; then | if [ "$c" = 3 ]; then | Quote variable. | Shell |
else
print('data') | else:
print('data') | Colon after else. | Python |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
x := 38 | x := 38 | Correct. | Go |
if (c = 26) {{}} | if (c === 26) {{}} | Use === for equality. | JavaScript |
arr(37) | if length(arr) >= 37, arr(37), end | Check length. | MATLAB |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if result = 1 | if result == 1 | Use ==. | Go |
compute | compute() | Add parentheses. | Kotlin |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
#footer {{ color: green; }} | #footer {{ color: green; }} | Correct. | CSS |
if temp = 93 | if temp == 93 | Use ==. | MATLAB |
'test' + 64 | 'test' + str(64) | Can't add int to string. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.