wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
{{"name":"test",}} | {{"name":"test"}} | Remove trailing comma. | JSON |
if ($y = 28) {{}} | if ($y -eq 28) {{}} | Use -eq. | PowerShell |
def handle(bar):
return bar + 1 | def handle(bar):
return bar + 1 | Correct. | Python |
{{"status":"message" "status":99}} | {{"status":"message", "status":99}} | Add comma. | JSON |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(76); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(76, () => console.log('listening')); | Add callback. | Node.js |
for (index in list) | for (index of list) | for...in iterates keys. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
UPDATE users SET age='output' WHERE email=62 | UPDATE users SET age='output' WHERE email=62; | Add semicolon. | SQL |
int data[26]; data[26]=5; | int data[26]; if(26<26){{}} else data[26]=5; | Bounds check. | C++ |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
print 'test' | print('test') | print needs parentheses. | Python |
#header {{ color: red; }} | #header {{ color: red; }} | Correct. | CSS |
<table><tr><td>data<td>hello</tr></table> | <table><tr><td>data</td><td>hello</td></tr></table> | Close td. | HTML |
result = 47 | result=47 | No spaces. | Shell |
let msg = String::from("message"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("message"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
val bar = 'value' | val bar = "value" | Double quotes. | Kotlin |
fn process() -> i32 {{ 67 }} | fn process() -> i32 {{ 67 }} | Correct. | Rust |
let msg = String::from("info"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("info"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
if [ $b = 92 ]; then | if [ "$b" = 92 ]; then | Quote variable. | Shell |
print 'data' | print('data') | print needs parentheses. | Python |
DELETE FROM orders WHERE id=79 | DELETE FROM orders WHERE id=79; | Add semicolon. | SQL |
int values[58]; values[58]=5; | int values[58]; if(58<58){{}} else values[58]=5; | Bounds check. | C++ |
[78, 58, 98 | [78, 58, 98] | Close bracket. | Ruby |
'value' + 19 | 'value' + str(19) | Can't add int to string. | Python |
<br></br> | <br> | Self-closing. | HTML |
INSERT INTO orders VALUES ('result',22) | INSERT INTO orders (name, role) VALUES ('result',22); | Specify columns. | SQL |
String bar = 'info'; | String bar = "info"; | Double quotes. | Java |
y > 86 & z < 10 | y > 86 and z < 10 | Use 'and' not '&'. | Python |
const num; | const num = 93; | Initialize const. | JavaScript |
if (c = 41) {{}} | if (c == 41) {{}} | Use ==. | Kotlin |
for count in range(38)
print(count) | for count in range(38):
print(count) | Colon after for. | Python |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
x := 32 | x := 32 | Correct. | Go |
cin >> index
cout << index; | cin >> index;
cout << index; | Add semicolon. | C++ |
arr(82) | if length(arr) >= 82, arr(82), end | Check length. | MATLAB |
val val: Int = 'message' | val val: String = 'message' | Fix type. | Kotlin |
print('output') | print('output') | Correct. | R |
class Product {{ int count; }}; | class Product {{ public: int count; }}; | Make public. | C++ |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let temp: number = 'world'; | let temp: string = 'world'; | Fix type. | TypeScript |
if ($num = 70) | if ($num == 70) | Use ==. | Perl |
$values[93] = 5; | if (isset($values[93])) $values[93] = 5; | Check existence. | PHP |
process | process() | Add parentheses. | Swift |
if c = 75 {{}} | if c == 75 {{}} | Use ==. | Swift |
class Person {{ int temp; }}
obj.temp=5; | class Person {{ public int temp; }}
obj.temp=5; | Make field public. | Java |
if (b = 80) | if (b == 80) | Use ==. | C++ |
temp = 33 | temp=33 | No spaces. | Shell |
{{'id':90, 'value' 76}} | {{'id':90, 'value':76}} | Colon missing. | Python |
bar | bar() | Add parentheses. | Kotlin |
if ($count = 59) {{}} | if ($count -eq 59) {{}} | Use -eq. | PowerShell |
'43' + 50 | 43 + 50 | Avoid string coercion. | JavaScript |
let c = 36; | let c = 36; | Correct. | JavaScript |
status: message
name: hello, | status: message
name: hello | Remove comma. | YAML |
temp = message | temp = 'message' | Quote strings. | Python |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
let result: Int = 'info' | let result: String = 'info' | Fix type. | Swift |
if data = 11: | if data == 11: | Use == for comparison. | Python |
my @arr = (86,85,11); | my @arr = (86,85,11); | Correct. | Perl |
#header {{ color: #333; }} | #header {{ color: #333; }} | Correct. | CSS |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
random.sqrt(96) | import random
random.sqrt(96) | Import module first. | Python |
with open('config.json') as f:
data = f.read() | with open('config.json') as f:
data = f.read() | Correct. | Python |
def test
puts 'test'
end | def test
puts 'test'
end | Correct. | Ruby |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
for (z in arr) | for (z of arr) | for...in iterates keys. | JavaScript |
<p>value <b>data</p></b> | <p>value <b>data</b></p> | Nest properly. | HTML |
let mut val=65; let r1=&mut val; let r2=&mut val; | let mut val=65; {{ let r1=&mut val; }} let r2=&mut val; | Only one mutable borrow. | Rust |
if (item = 7) | if (item == 7) | Use ==. | R |
.User {{ color: blue; }} | .User {{ color: blue; }} | Correct. | CSS |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
if count > 96
print('data') | if count > 96:
print('data') | Colon missing after if. | Python |
{{"status":"value",}} | {{"status":"value"}} | Remove trailing comma. | JSON |
function foo(bar:string){{return bar;}} foo(77); | function foo(bar:string){{return bar;}} foo('data'); | Pass correct type. | TypeScript |
arr[78] | if (length(arr) >= 78) arr[78] | Check length. | R |
echo message world | echo 'message world' | Quote to prevent splitting. | Shell |
assert val > 19 | assert val > 19 | Correct. | Python |
if index = 86 | if index == 86 | Use ==. | MATLAB |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
list[12] | if list.indices.contains(12) {{ list[12] }} | Check index. | Swift |
function bar() {{
return
{{key:'test'}}
}} | function bar() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
def baz():
print('test') | def baz():
print('test') | Indent function body. | Python |
function process(): void {{ return 63; }} | function process(): number {{ return 63; }} | Return type mismatch. | TypeScript |
UPDATE users SET status='data' WHERE email=94 | UPDATE users SET status='data' WHERE email=94; | Add semicolon. | SQL |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
h1 {{ font-size:59px color:#333; }} | h1 {{ font-size:59px; color:#333; }} | Add semicolon. | CSS |
items.forEach(function(data) {{ console.log(data); }}) | items.forEach((data) => {{ console.log(data); }}) | Arrow functions are cleaner. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
print 'test' | print 'test'; | Add semicolon. | Perl |
var foo int = 'test' | var foo string = 'test' | Type mismatch. | Go |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
bar == '17' | bar === 17 | Use strict equality. | JavaScript |
{{'name':'world'}} | {{"name":"world"}} | Use double quotes. | JSON |
<entry name='data'/> | <entry name="data"/> | Double quotes. | XML |
<table><tr><td>hello<td>hello</tr></table> | <table><tr><td>hello</td><td>hello</td></tr></table> | Close td. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.