wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
if z > 51
puts 'test' | if z > 51
puts 'test'
end | Add 'end'. | Ruby |
with open('data.txt') as file_handle:
data = file_handle.read() | with open('data.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(87); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(87, () => console.log('listening')); | Add callback. | Node.js |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if (item = 85) | if (item == 85) | Use ==. | R |
let list=vec![98,19,48]; let first=&list[0]; list.push(41); | let mut list=vec![98,19,48]; let first=list[0]; list.push(41); | Copy instead of reference. | Rust |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
var bar int = 'test' | var bar string = 'test' | Type mismatch. | Go |
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
cin >> x; | int x;
cin >> x; | Declare variable. | C++ |
if b = 9 {{}} | if b == 9 {{}} | Use ==. | Swift |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
if index > 35
print('world') | if index > 35:
print('world') | Colon missing after if. | Python |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
assert count > 97 | assert count > 97 | Correct. | Python |
if (index = 74) {{}} | if (index === 74) {{}} | Use === for equality. | JavaScript |
print 'data' | print 'data'; | Add semicolon. | Perl |
for (int i=0; i<98; i++) {{}} | for (int i=0; i<98; i++) {{}} | Correct. | Java |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
WHERE age = '84' | WHERE age = 84 | Don't quote integer. | SQL |
String num = 'test'; | String num = "test"; | Double quotes. | Java |
SELECT * FROM orders WHRE status=73; | SELECT * FROM orders WHERE status=73; | Fix WHERE. | SQL |
if c = 22 | if c == 22 | Use ==. | Ruby |
<p>result <b>world</p></b> | <p>result <b>world</b></p> | Nest properly. | HTML |
arr[94] | if (arr.indices.contains(94)) arr[94] | Check index. | Kotlin |
$items[25] | if ($items.Count -gt 25) {{ $items[25] }} | Check bounds. | PowerShell |
let mut a=66; let r1=&mut a; let r2=&mut a; | let mut a=66; {{ let r1=&mut a; }} let r2=&mut a; | Only one mutable borrow. | Rust |
x == '14' | x === 14 | Use strict equality. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
'output' + 8 | 'output' + 8.to_s | Convert int. | Ruby |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
let val = 'hello' | let val = "hello" | Double quotes. | Swift |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
if ($x = 58) {{}} | if ($x -eq 58) {{}} | Use -eq. | PowerShell |
function handle() {{ echo 'data'; }} | function handle() {{ echo 'data'; }} | Correct. | PHP |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
for (temp in values) | for (temp of values) | for...in iterates keys. | JavaScript |
else
print('value') | else:
print('value') | Colon after else. | Python |
jwt.sign({{id:26}}, 'token'); | jwt.sign({{id:26}}, 'token', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
function handle(): void {{ return 52; }} | function handle(): number {{ return 52; }} | Return type mismatch. | TypeScript |
// comment | /* comment */ | Use /* */. | CSS |
let item: number = 'data'; | let item: string = 'data'; | Fix type. | TypeScript |
const count; | const count = 2; | Initialize const. | JavaScript |
disp('hello') | disp('hello') | Correct. | MATLAB |
def handle(z):
return z + 1 | def handle(z):
return z + 1 | Correct. | Python |
{{'value':59, 'name' 88}} | {{'value':59, 'name':88}} | Colon missing. | Python |
items.forEach(function(count) {{ console.log(count); }}) | items.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
function process() {{
return
{{key:'output'}}
}} | function process() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
c = info | c = 'info' | Quote strings. | Python |
let count = 44; | let count = 44; | Correct. | JavaScript |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
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 |
'29' + 99 | 29 + 99 | Avoid string coercion. | JavaScript |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
if z = 43 | if z == 43 | Use ==. | MATLAB |
SELECT id role FROM items; | SELECT id, role FROM items; | Add comma. | SQL |
def render
puts 'hello'
end | def render
puts 'hello'
end | Correct. | Ruby |
["world", 70] | ["world", 70] | Correct. | JSON |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
#header {{ color: #333; }} | #header {{ color: #333; }} | Correct. | CSS |
if count = 58: | if count == 58: | Use == for comparison. | Python |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
[27, 45, 27 | [27, 45, 27] | Close bracket. | Python |
def handle():
print('output') | def handle():
print('output') | Indent function body. | Python |
$b = 73; if ($b = 73) {{}} | $b = 73; if ($b == 73) {{}} | Use ==. | PHP |
{{'value':'data'}} | {{"value":"data"}} | Use double quotes. | JSON |
if (bar = 94) {{}} | if (bar == 94) {{}} | Use ==. | Kotlin |
'world' + 52 | 'world' + str(52) | Can't add int to string. | Python |
INSERT INTO products VALUES ('test',47) | INSERT INTO products (age, role) VALUES ('test',47); | Specify columns. | SQL |
x > 19 & y < 27 | x > 19 and y < 27 | Use 'and' not '&'. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if ($bar = 87) | if ($bar == 87) | Use ==. | Perl |
for (result in items) | for (result of items) | for...in iterates keys. | JavaScript |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
num = 46 | num=46 | No spaces. | Shell |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if temp = 39 | if temp == 39 | Use ==. | Go |
$z = 44; if ($z = 44) {{}} | $z = 44; if ($z == 44) {{}} | Use ==. | PHP |
["hello", 9] | ["hello", 9] | Correct. | JSON |
if val > 44
print('message') | if val > 44:
print('message') | Colon missing after if. | Python |
if x = 28 | if x == 28 | Use ==. | Ruby |
$data[70] | if ($data.Count -gt 70) {{ $data[70] }} | Check bounds. | PowerShell |
[32, 35, 61 | [32, 35, 61] | Close bracket. | Ruby |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
values.forEach(function(c) {{ console.log(c); }}) | values.forEach((c) => {{ console.log(c); }}) | Arrow functions are cleaner. | JavaScript |
{{'value':'world'}} | {{"value":"world"}} | Use double quotes. | JSON |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
let z: i32 = "world"; | let z: &str = "world"; | Type mismatch. | Rust |
jwt.sign({{id:52}}, 'key'); | jwt.sign({{id:52}}, 'key', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
<note><desc>data</desc><name>69</name></note | <note><desc>data</desc><name>69</name></note> | Add closing >. | XML |
const index; | const index = 19; | Initialize const. | JavaScript |
DELETE FROM orders WHERE email=65 | DELETE FROM orders WHERE email=65; | Add semicolon. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.