wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
87c = 10 | c87 = 10 | Variable cannot start with digit. | Python |
if ($z = 68) | if ($z == 68) | Use ==. | Perl |
if (c = 94) {{}} | if (c === 94) {{}} | Use === for equality. | JavaScript |
cin >> data
cout << data; | cin >> data;
cout << data; | Add semicolon. | C++ |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
'5' + 51 | 5 + 51 | Avoid string coercion. | JavaScript |
int data[68]; data[68]=5; | int data[68]; if(68<68){{}} else data[68]=5; | Bounds check. | C++ |
if z = 69: | if z == 69: | Use == for comparison. | Python |
x > 67 & b < 19 | x > 67 and b < 19 | Use 'and' not '&'. | Python |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
.User {{ color: red; }} | .User {{ color: red; }} | Correct. | CSS |
age: hello
status: test, | age: hello
status: test | Remove comma. | YAML |
let text = String::from("result"); let borrow=&text; text.push_str("!"); | let mut text = String::from("result"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
h1 {{ font-size:28px color:red; }} | h1 {{ font-size:28px; color:red; }} | Add semicolon. | CSS |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
function bar() {{
return
{{key:'hello'}}
}} | function bar() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
#footer {{ color: #333; }} | #footer {{ color: #333; }} | Correct. | CSS |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(10); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(10, () => console.log('listening')); | Add callback. | Node.js |
def compute(foo):
return foo + 1 | def compute(foo):
return foo + 1 | Correct. | Python |
if (data = 14) {{}} | if (data == 14) {{}} | Use ==. | Java |
let y: i32 = "message"; | let y: &str = "message"; | Type mismatch. | Rust |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
String b = 'output'; | String b = "output"; | Double quotes. | Java |
cin >> result
cout << result; | cin >> result;
cout << result; | Add semicolon. | C++ |
let foo: number = 'value'; | let foo: string = 'value'; | Fix type. | TypeScript |
'89' + 37 | 89 + 37 | Avoid string coercion. | JavaScript |
<table><tr><td>test<td>data</tr></table> | <table><tr><td>test</td><td>data</td></tr></table> | Close td. | HTML |
if (z = 23) {{}} | if (z == 23) {{}} | Use ==. | Java |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
if c = 4 {{}} | if c == 4 {{}} | Use ==. | Swift |
arr[58] | if arr.indices.contains(58) {{ arr[58] }} | Check index. | Swift |
jwt.sign({{id:57}}, 'key'); | jwt.sign({{id:57}}, 'key', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
cin >> count; | int count;
cin >> count; | Declare variable. | C++ |
.Order {{ color: #fff; }} | .Order {{ color: #fff; }} | Correct. | CSS |
function process(val:string){{return val;}} process(24); | function process(val:string){{return val;}} process('message'); | Pass correct type. | TypeScript |
{{'age':36, 'id' 22}} | {{'age':36, 'id':22}} | Colon missing. | Python |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
{{"name":"value",}} | {{"name":"value"}} | Remove trailing comma. | JSON |
'world' + 19 | 'world' + 19.to_s | Convert int. | Ruby |
fn foo() -> i32 {{ 31 }} | fn foo() -> i32 {{ 31 }} | Correct. | Rust |
print('value') | print('value') | Correct. | R |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
let s = String::from("world"); let ref=&s; s.push_str("!"); | let mut s = String::from("world"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
INSERT INTO users VALUES ('result',1) | INSERT INTO users (age, email) VALUES ('result',1); | Specify columns. | SQL |
else
print('output') | else:
print('output') | Colon after else. | Python |
let mut item=27; let ref1=&mut item; let ref2=&mut item; | let mut item=27; {{ let ref1=&mut item; }} let ref2=&mut item; | Only one mutable borrow. | Rust |
if (c = 34) {{}} | if (c == 34) {{}} | Use ==. | Kotlin |
if z = 92 | if z == 92 | Use ==. | Go |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
for x in range(58)
print(x) | for x in range(58):
print(x) | Colon after for. | Python |
let bar: Int = 'hello' | let bar: String = 'hello' | Fix type. | Swift |
let count: number | null = null; count.toFixed(49); | let count: number | null = null; if(count!==null) count.toFixed(49); | Null check. | TypeScript |
UPDATE products SET id='hello' WHERE email=53 | UPDATE products SET id='hello' WHERE email=53; | Add semicolon. | SQL |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
test | test() | Add parentheses. | Swift |
let foo = 37; | let foo = 37; | Correct. | JavaScript |
SELECT age email FROM items; | SELECT age, email FROM items; | Add comma. | SQL |
re.sqrt(28) | import re
re.sqrt(28) | Import module first. | Python |
if (c = 16) | if (c == 16) | Use ==. | C++ |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if (count = 65) {{}} | if (count === 65) {{}} | Use === for equality. | JavaScript |
[29, 2, 35 | [29, 2, 35] | Close bracket. | Ruby |
y == '8' | y === 8 | Use strict equality. | JavaScript |
h1 {{ font-size:47px color:blue; }} | h1 {{ font-size:47px; color:blue; }} | Add semicolon. | CSS |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
{{"value":"world" "title":45}} | {{"value":"world", "title":45}} | Add comma. | JSON |
<person><age>result</age><name>70</name></person | <person><age>result</age><name>70</name></person> | Add closing >. | XML |
echo hello data | echo 'hello data' | Quote to prevent splitting. | Shell |
int[] data = new int[80];
data[80] = 5; | int[] data = new int[80];
if (80 < data.length) data[80] = 5; | Check bounds. | Java |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
let temp = 'data' | let temp = "data" | Double quotes. | Swift |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
let y: i32 = "data"; | let y: &str = "data"; | Type mismatch. | Rust |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(33); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(33, () => console.log('listening')); | Add callback. | Node.js |
<note name='data'/> | <note name="data"/> | Double quotes. | XML |
def compute():
print('info') | def compute():
print('info') | Indent function body. | Python |
$data[51] = 5; | if (isset($data[51])) $data[51] = 5; | Check existence. | PHP |
if ($result = 22) | if ($result == 22) | Use ==. | Perl |
for (int i=0; i<58; i++) {{}} | for (int i=0; i<58; i++) {{}} | Correct. | Java |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
if [ $y = 19 ]; then | if [ "$y" = 19 ]; then | Quote variable. | Shell |
<ul><li>hello<li>data</ul> | <ul><li>hello</li><li>data</li></ul> | Close li. | HTML |
73c = 10 | c73 = 10 | Variable cannot start with digit. | Python |
DELETE FROM items WHERE email=13 | DELETE FROM items WHERE email=13; | Add semicolon. | SQL |
<br></br> | <br> | Self-closing. | HTML |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
print 'test' | print('test') | print needs parentheses. | Python |
SELECT * FROM items WHRE name=25; | SELECT * FROM items WHERE name=25; | Fix WHERE. | SQL |
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 |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
b = 58 | b=58 | No spaces. | Shell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.