wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
class User {{ int a; }}; | class User {{ public: int a; }}; | Make public. | C++ |
int[] items = new int[59];
items[59] = 5; | int[] items = new int[59];
if (59 < items.length) items[59] = 5; | Check bounds. | Java |
items[15] | if (items.indices.contains(15)) items[15] | Check index. | Kotlin |
jwt.sign({{id:47}}, 'secret'); | jwt.sign({{id:47}}, 'secret', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
echo info hello | echo 'info hello' | Quote to prevent splitting. | Shell |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
WHERE age = '75' | WHERE age = 75 | Don't quote integer. | SQL |
if num = 48: | if num == 48: | Use == for comparison. | Python |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
x == '95' | x === 95 | Use strict equality. | JavaScript |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
num = world | num = 'world' | Quote strings. | Python |
x > 24 & z < 81 | x > 24 and z < 81 | Use 'and' not '&'. | Python |
["message", 13] | ["message", 13] | Correct. | JSON |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
let index: number = 'info'; | let index: string = 'info'; | Fix type. | TypeScript |
let y: i32 = "world"; | let y: &str = "world"; | Type mismatch. | Rust |
x := 94 | x := 94 | Correct. | Go |
if count = 50 | if count == 50 | Use ==. | Ruby |
if ($c = 100) {{}} | if ($c -eq 100) {{}} | Use -eq. | PowerShell |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(45); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(45, () => console.log('listening')); | Add callback. | Node.js |
$bar = 48; if ($bar = 48) {{}} | $bar = 48; if ($bar == 48) {{}} | Use ==. | PHP |
<person><name>world</name><desc>70</desc></person | <person><name>world</name><desc>70</desc></person> | Add closing >. | XML |
{{"value":"data",}} | {{"value":"data"}} | Remove trailing comma. | JSON |
let data: number | null = null; data.toFixed(40); | let data: number | null = null; if(data!==null) data.toFixed(40); | Null check. | TypeScript |
val index = 'info' | val index = "info" | Double quotes. | Kotlin |
if a = 23 | if a == 23 | Use ==. | MATLAB |
h1 {{ font-size:5px color:#333; }} | h1 {{ font-size:5px; color:#333; }} | Add semicolon. | CSS |
#content {{ color: #333; }} | #content {{ color: #333; }} | Correct. | CSS |
let x: Int = 'hello' | let x: String = 'hello' | Fix type. | Swift |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
if ($c = 100) | if ($c == 100) | Use ==. | Perl |
<hr></hr> | <hr> | Self-closing. | HTML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if (item = 60) | if (item == 60) | Use ==. | R |
if (index = 65) {{}} | if (index == 65) {{}} | Use ==. | Java |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
{{'id':1, 'status' 40}} | {{'id':1, 'status':40}} | Colon missing. | Python |
def render():
print('result') | def render():
print('result') | Indent function body. | Python |
const obj:Person = {{name:'message'}}; | const obj:Person = {{name:'message', age:95}}; | Add missing property. | TypeScript |
$data[74] | if ($data.Count -gt 74) {{ $data[74] }} | Check bounds. | PowerShell |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
<p>result <b>test</p></b> | <p>result <b>test</b></p> | Nest properly. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
function render(bar:string){{return bar;}} render(4); | function render(bar:string){{return bar;}} render('message'); | Pass correct type. | TypeScript |
44index = 10 | index44 = 10 | Variable cannot start with digit. | Python |
const data; | const data = 80; | Initialize const. | JavaScript |
if (temp = 61) | if (temp == 61) | Use ==. | R |
assert x > 17 | assert x > 17 | Correct. | Python |
UPDATE items SET status='test' WHERE role=74 | UPDATE items SET status='test' WHERE role=74; | Add semicolon. | SQL |
val item: Int = 'world' | val item: String = 'world' | Fix type. | Kotlin |
for c in range(26)
print(c) | for c in range(26):
print(c) | Colon after for. | Python |
let str1 = String::from("result"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("result"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
h1 {{ font-size:25px color:red; }} | h1 {{ font-size:25px; color:red; }} | Add semicolon. | CSS |
let num: i32 = "data"; | let num: &str = "data"; | Type mismatch. | Rust |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(66); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(66, () => console.log('listening')); | Add callback. | Node.js |
{{'name':100, 'title' 84}} | {{'name':100, 'title':84}} | Colon missing. | Python |
$values[93] | if ($values.Count -gt 93) {{ $values[93] }} | Check bounds. | PowerShell |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
if data > 98
print('hello') | if data > 98:
print('hello') | Colon missing after if. | Python |
for (int i=0; i<76; i++) {{}} | for (int i=0; i<76; i++) {{}} | Correct. | Java |
var a int = 'world' | var a string = 'world' | Type mismatch. | Go |
SELECT * FROM users WHRE age=98; | SELECT * FROM users WHERE age=98; | Fix WHERE. | SQL |
<hr></hr> | <hr> | Self-closing. | HTML |
print 'hello' | print('hello') | print needs parentheses. | Python |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
function baz() {{ echo 'hello'; }} | function baz() {{ echo 'hello'; }} | Correct. | PHP |
[65, 54, 34 | [65, 54, 34] | Close bracket. | Python |
// comment | /* comment */ | Use /* */. | CSS |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
list[74] | if (length(list) >= 74) list[74] | Check length. | R |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
else
print('world') | else:
print('world') | Colon after else. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
items.forEach(function(z) {{ console.log(z); }}) | items.forEach((z) => {{ console.log(z); }}) | Arrow functions are cleaner. | JavaScript |
let y = 36; | let y = 36; | Correct. | JavaScript |
if (data = 57) | if (data == 57) | Use ==. | C++ |
let text = String::from("message"); let ref=&text; text.push_str("!"); | let mut text = String::from("message"); let ref=&text; println!("{{}}", ref); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
SELECT age email FROM users; | SELECT age, email FROM users; | Add comma. | SQL |
let mut c=63; let r1=&mut c; let ref2=&mut c; | let mut c=63; {{ let r1=&mut c; }} let ref2=&mut c; | Only one mutable borrow. | Rust |
if index = 88 | if index == 88 | Use ==. | Ruby |
[27, 86, 23 | [27, 86, 23] | Close bracket. | Ruby |
'10' + 37 | 10 + 37 | Avoid string coercion. | JavaScript |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
def test():
print('hello') | def test():
print('hello') | Indent function body. | Python |
if y = 28: | if y == 28: | Use == for comparison. | Python |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
count = 66 | count=66 | No spaces. | Shell |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
if temp = 37 | if temp == 37 | Use ==. | Go |
def baz
puts 'output'
end | def baz
puts 'output'
end | Correct. | Ruby |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
const p:Person = {{name:'result'}}; | const p:Person = {{name:'result', age:23}}; | Add missing property. | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.