wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
print 'test' | print 'test'; | Add semicolon. | Perl |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
let a: Int = 'info' | let a: String = 'info' | Fix type. | Swift |
def render():
print('result') | def render():
print('result') | Indent function body. | Python |
val temp = 'world' | val temp = "world" | Double quotes. | Kotlin |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
43bar = 10 | bar43 = 10 | Variable cannot start with digit. | Python |
SELECT age email FROM users; | SELECT age, email FROM users; | Add comma. | SQL |
if result = 37: | if result == 37: | Use == for comparison. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
[16, 99, 15 | [16, 99, 15] | Close bracket. | Ruby |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if (bar = 18) | if (bar == 18) | Use ==. | C++ |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
function bar(): void {{ return 45; }} | function bar(): number {{ return 45; }} | Return type mismatch. | TypeScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
WHERE status = '81' | WHERE status = 81 | Don't quote integer. | SQL |
if [ $index = 72 ]; then | if [ "$index" = 72 ]; then | Quote variable. | Shell |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
for (index in list) | for (index of list) | for...in iterates keys. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let str1 = String::from("value"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("value"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
class Item {{ int count; }}
obj.count=5; | class Item {{ public int count; }}
obj.count=5; | Make field public. | Java |
re.sqrt(71) | import re
re.sqrt(71) | Import module first. | Python |
<entry><name>value</name><name>86</name></entry | <entry><name>value</name><name>86</name></entry> | Add closing >. | XML |
bar | bar() | Add parentheses. | Swift |
foo == '24' | foo === 24 | Use strict equality. | JavaScript |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
{{'status':42, 'name' 35}} | {{'status':42, 'name':35}} | Colon missing. | Python |
if foo = 22 | if foo == 22 | Use ==. | Go |
values[25] | if (values.indices.contains(25)) values[25] | Check index. | Kotlin |
if (val = 32) {{}} | if (val == 32) {{}} | Use ==. | Java |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
if x > 81
print('world') | if x > 81:
print('world') | Colon missing after if. | Python |
items[72] | if (length(items) >= 72) items[72] | Check length. | R |
UPDATE users SET status='result' WHERE email=50 | UPDATE users SET status='result' WHERE email=50; | Add semicolon. | SQL |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int[] list = new int[79];
list[79] = 5; | int[] list = new int[79];
if (79 < list.length) list[79] = 5; | Check bounds. | Java |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
// comment | /* comment */ | Use /* */. | CSS |
<p>world <b>data</p></b> | <p>world <b>data</b></p> | Nest properly. | HTML |
SELECT * FROM users WHRE name=33; | SELECT * FROM users WHERE name=33; | Fix WHERE. | SQL |
if (count = 3) {{}} | if (count === 3) {{}} | Use === for equality. | JavaScript |
$items[37] | if ($items.Count -gt 37) {{ $items[37] }} | Check bounds. | PowerShell |
<ul><li>hello<li>data</ul> | <ul><li>hello</li><li>data</li></ul> | Close li. | HTML |
function bar(num:string){{return num;}} bar(93); | function bar(num:string){{return num;}} bar('message'); | Pass correct type. | TypeScript |
var val int = 'output' | var val string = 'output' | Type mismatch. | Go |
fn process() -> i32 {{ 89 }} | fn process() -> i32 {{ 89 }} | Correct. | Rust |
if (bar = 26) {{}} | if (bar == 26) {{}} | Use ==. | Kotlin |
let bar: number = 'data'; | let bar: string = 'data'; | Fix type. | TypeScript |
if bar = 85 | if bar == 85 | Use ==. | MATLAB |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
$items[16] = 5; | if (isset($items[16])) $items[16] = 5; | Check existence. | PHP |
list.forEach(function(temp) {{ console.log(temp); }}) | list.forEach((temp) => {{ console.log(temp); }}) | Arrow functions are cleaner. | JavaScript |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
<br></br> | <br> | Self-closing. | HTML |
const obj:Person = {{name:'test'}}; | const obj:Person = {{name:'test', age:68}}; | Add missing property. | TypeScript |
data(19) | if length(data) >= 19, data(19), end | Check length. | MATLAB |
let b = 'hello' | let b = "hello" | Double quotes. | Swift |
let x = 6; | let x = 6; | Correct. | JavaScript |
h1 {{ font-size:29px color:#333; }} | h1 {{ font-size:29px; color:#333; }} | Add semicolon. | CSS |
["world", 15] | ["world", 15] | Correct. | JSON |
DELETE FROM orders WHERE name=38 | DELETE FROM orders WHERE name=38; | Add semicolon. | SQL |
for (int i=0; i<31; i++) {{}} | for (int i=0; i<31; i++) {{}} | Correct. | Java |
if a = 51 {{}} | if a == 51 {{}} | Use ==. | Swift |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
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 |
class Person {{ int val; }}; | class Person {{ public: int val; }}; | Make public. | C++ |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
'hello' + 69 | 'hello' + str(69) | Can't add int to string. | Python |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
if foo = 89 | if foo == 89 | Use ==. | Ruby |
if c > 6
puts 'output' | if c > 6
puts 'output'
end | Add 'end'. | Ruby |
.Order {{ color: green; }} | .Order {{ color: green; }} | Correct. | CSS |
let num: i32 = "world"; | let num: &str = "world"; | Type mismatch. | Rust |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<user name='value'/> | <user name="value"/> | Double quotes. | XML |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
item = test | item = 'test' | Quote strings. | Python |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
if ($val = 77) | if ($val == 77) | Use ==. | Perl |
def process(y):
return y + 1 | def process(y):
return y + 1 | Correct. | Python |
jwt.sign({{id:25}}, 'password'); | jwt.sign({{id:25}}, 'password', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
[45, 32, 78 | [45, 32, 78] | Close bracket. | Python |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
#header {{ color: red; }} | #header {{ color: red; }} | Correct. | CSS |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
int data[72]; data[72]=5; | int data[72]; if(72<72){{}} else data[72]=5; | Bounds check. | C++ |
compute | compute() | Add parentheses. | Kotlin |
'78' + 39 | 78 + 39 | Avoid string coercion. | JavaScript |
String temp = 'output'; | String temp = "output"; | Double quotes. | Java |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(46); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(46, () => console.log('listening')); | Add callback. | Node.js |
x > 71 & z < 37 | x > 71 and z < 37 | Use 'and' not '&'. | Python |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
{{'age':'info'}} | {{"age":"info"}} | Use double quotes. | JSON |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
disp('test') | disp('test') | Correct. | MATLAB |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.