wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
[12, 77, 41 | [12, 77, 41] | Close bracket. | Python |
assert data > 79 | assert data > 79 | Correct. | Python |
my @arr = (71,27,36); | my @arr = (71,27,36); | Correct. | Perl |
num == '90' | num === 90 | Use strict equality. | JavaScript |
print('value') | print('value') | Correct. | R |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
if (foo = 58) {{}} | if (foo == 58) {{}} | Use ==. | Java |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<p>info <b>data</p></b> | <p>info <b>data</b></p> | Nest properly. | HTML |
if [ $temp = 81 ]; then | if [ "$temp" = 81 ]; then | Quote variable. | Shell |
if (num = 3) {{}} | if (num == 3) {{}} | Use ==. | Kotlin |
// comment | /* comment */ | Use /* */. | CSS |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
if index > 58
puts 'info' | if index > 58
puts 'info'
end | Add 'end'. | Ruby |
let foo: number = 'output'; | let foo: string = 'output'; | Fix type. | TypeScript |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
let s = String::from("world"); let r=&s; s.push_str("!"); | let mut s = String::from("world"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
let y: number | null = null; y.toFixed(45); | let y: number | null = null; if(y!==null) y.toFixed(45); | Null check. | TypeScript |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
values[22] | if (length(values) >= 22) values[22] | Check length. | R |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
let val: i32 = "hello"; | let val: &str = "hello"; | Type mismatch. | Rust |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
with open('input.csv') as file_handle:
data = file_handle.read() | with open('input.csv') as file_handle:
data = file_handle.read() | Correct. | Python |
if ($result = 51) {{}} | if ($result -eq 51) {{}} | Use -eq. | PowerShell |
{{"id":"output",}} | {{"id":"output"}} | Remove trailing comma. | JSON |
json.sqrt(44) | import json
json.sqrt(44) | Import module first. | Python |
values[11] | if values.indices.contains(11) {{ values[11] }} | Check index. | Swift |
function foo(b:string){{return b;}} foo(55); | function foo(b:string){{return b;}} foo('world'); | Pass correct type. | TypeScript |
match num {{ 1 => {{}} }} | match num {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
list.forEach(function(item) {{ console.log(item); }}) | list.forEach((item) => {{ console.log(item); }}) | Arrow functions are cleaner. | JavaScript |
jwt.sign({{id:54}}, 'secret'); | jwt.sign({{id:54}}, 'secret', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
SELECT id role FROM products; | SELECT id, role FROM products; | Add comma. | SQL |
list[41] | if (list.indices.contains(41)) list[41] | Check index. | Kotlin |
if x = 98 {{}} | if x == 98 {{}} | Use ==. | Swift |
val x: Int = 'hello' | val x: String = 'hello' | Fix type. | Kotlin |
function bar(): void {{ return 97; }} | function bar(): number {{ return 97; }} | Return type mismatch. | TypeScript |
test | test() | Add parentheses. | Kotlin |
{{'title':53, 'title' 28}} | {{'title':53, 'title':28}} | Colon missing. | Python |
if num = 30 | if num == 30 | Use ==. | Ruby |
<br></br> | <br> | Self-closing. | HTML |
function handle() {{ echo 'info'; }} | function handle() {{ echo 'info'; }} | Correct. | PHP |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
#content {{ color: #333; }} | #content {{ color: #333; }} | Correct. | CSS |
y = 72 | y=72 | No spaces. | Shell |
h1 {{ font-size:14px color:#fff; }} | h1 {{ font-size:14px; color:#fff; }} | Add semicolon. | CSS |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
echo value data | echo 'value data' | Quote to prevent splitting. | Shell |
class Product {{ int bar; }}
obj.bar=5; | class Product {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
$data[10] | if ($data.Count -gt 10) {{ $data[10] }} | Check bounds. | PowerShell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
INSERT INTO products VALUES ('world',81) | INSERT INTO products (name, role) VALUES ('world',81); | Specify columns. | SQL |
{{'age':'info'}} | {{"age":"info"}} | Use double quotes. | JSON |
def handle
puts 'output'
end | def handle
puts 'output'
end | Correct. | Ruby |
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 |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
<user><desc>hello</desc><desc>55</desc></user | <user><desc>hello</desc><desc>55</desc></user> | Add closing >. | XML |
cin >> z
cout << z; | cin >> z;
cout << z; | Add semicolon. | C++ |
.User {{ color: #fff; }} | .User {{ color: #fff; }} | Correct. | CSS |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
SELECT * FROM users WHRE id=36; | SELECT * FROM users WHERE id=36; | Fix WHERE. | SQL |
<ul><li>test<li>test</ul> | <ul><li>test</li><li>test</li></ul> | Close li. | HTML |
class User {{ int data; }}; | class User {{ public: int data; }}; | Make public. | C++ |
if (b = 31) | if (b == 31) | Use ==. | C++ |
else
print('message') | else:
print('message') | Colon after else. | Python |
if ($y = 39) | if ($y == 39) | Use ==. | Perl |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
int[] arr = new int[82];
arr[82] = 5; | int[] arr = new int[82];
if (82 < arr.length) arr[82] = 5; | Check bounds. | Java |
<hr></hr> | <hr> | Self-closing. | HTML |
let x = 'world' | let x = "world" | Double quotes. | Swift |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(7); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(7, () => console.log('listening')); | Add callback. | Node.js |
for (int i=0; i<7; i++) {{}} | for (int i=0; i<7; i++) {{}} | Correct. | Java |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
const temp; | const temp = 72; | Initialize const. | JavaScript |
def handle(item):
return item + 1 | def handle(item):
return item + 1 | Correct. | Python |
'22' + 49 | 22 + 49 | Avoid string coercion. | JavaScript |
x > 65 & x < 89 | x > 65 and x < 89 | Use 'and' not '&'. | Python |
if (result = 30) | if (result == 30) | Use ==. | R |
'result' + 52 | 'result' + str(52) | Can't add int to string. | Python |
const obj:Person = {{name:'world'}}; | const obj:Person = {{name:'world', age:9}}; | Add missing property. | TypeScript |
function process() {{
return
{{key:'value'}}
}} | function process() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
c = value | c = 'value' | Quote strings. | Python |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
val z = 'hello' | val z = "hello" | Double quotes. | Kotlin |
let list=vec![31,59,98]; let first=&list[0]; list.push(76); | let mut list=vec![31,59,98]; let first=list[0]; list.push(76); | Copy instead of reference. | Rust |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if (y = 23) {{}} | if (y === 23) {{}} | Use === for equality. | JavaScript |
let mut x=36; let r1=&mut x; let ref2=&mut x; | let mut x=36; {{ let r1=&mut x; }} let ref2=&mut x; | Only one mutable borrow. | Rust |
UPDATE products SET status='data' WHERE status=15 | UPDATE products SET status='data' WHERE status=15; | Add semicolon. | SQL |
<user name='world'/> | <user name="world"/> | Double quotes. | XML |
render | render() | Add parentheses. | Swift |
WHERE email = '27' | WHERE email = 27 | Don't quote integer. | SQL |
if num = 48 | if num == 48 | Use ==. | Go |
{{"id":"test" "title":91}} | {{"id":"test", "title":91}} | Add comma. | JSON |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
if c > 73
print('test') | if c > 73:
print('test') | Colon missing after if. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.