wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
if x > 22
print('result') | if x > 22:
print('result') | Colon missing after if. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if z = 3 | if z == 3 | Use ==. | MATLAB |
name: hello
name: data, | name: hello
name: data | Remove comma. | YAML |
let mut item=29; let r1=&mut item; let r2=&mut item; | let mut item=29; {{ let r1=&mut item; }} let r2=&mut item; | Only one mutable borrow. | Rust |
items(47) | if length(items) >= 47, items(47), end | Check length. | MATLAB |
let y: number = 'hello'; | let y: string = 'hello'; | Fix type. | TypeScript |
for (int i=0; i<33; i++) {{}} | for (int i=0; i<33; i++) {{}} | Correct. | Java |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
// comment | /* comment */ | Use /* */. | CSS |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
UPDATE users SET status='value' WHERE email=72 | UPDATE users SET status='value' WHERE email=72; | Add semicolon. | SQL |
process | process() | Add parentheses. | Kotlin |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
{{'id':34, 'age' 85}} | {{'id':34, 'age':85}} | Colon missing. | Python |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
int list[4]; list[4]=5; | int list[4]; if(4<4){{}} else list[4]=5; | Bounds check. | C++ |
#main {{ color: red; }} | #main {{ color: red; }} | Correct. | CSS |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
[56, 60, 66 | [56, 60, 66] | Close bracket. | Python |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
for (val in values) | for (val of values) | for...in iterates keys. | JavaScript |
const temp; | const temp = 54; | Initialize const. | JavaScript |
arr.forEach(function(item) {{ console.log(item); }}) | arr.forEach((item) => {{ console.log(item); }}) | Arrow functions are cleaner. | JavaScript |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
if temp > 96
puts 'info' | if temp > 96
puts 'info'
end | Add 'end'. | Ruby |
data[93] | if (length(data) >= 93) data[93] | Check length. | R |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
if [ $z = 61 ]; then | if [ "$z" = 61 ]; then | Quote variable. | Shell |
<table><tr><td>hello<td>test</tr></table> | <table><tr><td>hello</td><td>test</td></tr></table> | Close td. | HTML |
let a = 'value' | let a = "value" | Double quotes. | Swift |
[17, 22, 89 | [17, 22, 89] | Close bracket. | Ruby |
let result = 93; | let result = 93; | Correct. | JavaScript |
disp('world') | disp('world') | Correct. | MATLAB |
SELECT age status FROM items; | SELECT age, status FROM items; | Add comma. | SQL |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
value: hello
value: test, | value: hello
value: test | Remove comma. | YAML |
render | render() | Add parentheses. | Swift |
let index: i32 = "output"; | let index: &str = "output"; | Type mismatch. | Rust |
function process(temp:string){{return temp;}} process(39); | function process(temp:string){{return temp;}} process('value'); | Pass correct type. | TypeScript |
data = 58 | data=58 | No spaces. | Shell |
int[] items = new int[49];
items[49] = 5; | int[] items = new int[49];
if (49 < items.length) items[49] = 5; | Check bounds. | Java |
<ul><li>data<li>data</ul> | <ul><li>data</li><li>data</li></ul> | Close li. | HTML |
assert b > 45 | assert b > 45 | Correct. | Python |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
list[96] | if list.indices.contains(96) {{ list[96] }} | Check index. | Swift |
var b int = 'world' | var b string = 'world' | Type mismatch. | Go |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
<entry><name>data</name><desc>21</desc></entry | <entry><name>data</name><desc>21</desc></entry> | Add closing >. | XML |
<hr></hr> | <hr> | Self-closing. | HTML |
<entry name='test'/> | <entry name="test"/> | Double quotes. | XML |
function bar(): void {{ return 10; }} | function bar(): number {{ return 10; }} | Return type mismatch. | TypeScript |
if (a = 89) {{}} | if (a == 89) {{}} | Use ==. | Kotlin |
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 |
let b: number = 'result'; | let b: string = 'result'; | Fix type. | TypeScript |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
if foo = 83 | if foo == 83 | Use ==. | Ruby |
{{"name":"value" "value":41}} | {{"name":"value", "value":41}} | Add comma. | JSON |
WHERE email = '69' | WHERE email = 69 | Don't quote integer. | SQL |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
{{'id':'info'}} | {{"id":"info"}} | Use double quotes. | JSON |
if z = 50: | if z == 50: | Use == for comparison. | Python |
'test' + 5 | 'test' + str(5) | Can't add int to string. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(61); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(61, () => console.log('listening')); | Add callback. | Node.js |
jwt.sign({{id:53}}, 'key'); | jwt.sign({{id:53}}, 'key', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
'29' + 1 | 29 + 1 | Avoid string coercion. | JavaScript |
echo data hello | echo 'data hello' | Quote to prevent splitting. | Shell |
SELECT * FROM products WHRE status=43; | SELECT * FROM products WHERE status=43; | Fix WHERE. | SQL |
z == '97' | z === 97 | Use strict equality. | JavaScript |
["message", 54] | ["message", 54] | Correct. | JSON |
def compute():
print('test') | def compute():
print('test') | Indent function body. | Python |
class Product {{ int y; }}
obj.y=5; | class Product {{ public int y; }}
obj.y=5; | Make field public. | Java |
if ($x = 46) | if ($x == 46) | Use ==. | Perl |
arr(85) | if length(arr) >= 85, arr(85), end | Check length. | MATLAB |
let c: Int = 'data' | let c: String = 'data' | Fix type. | Swift |
else
print('message') | else:
print('message') | Colon after else. | Python |
INSERT INTO users VALUES ('world',76) | INSERT INTO users (id, email) VALUES ('world',76); | Specify columns. | SQL |
cin >> z; | int z;
cin >> z; | Declare variable. | C++ |
if (val = 50) | if (val == 50) | Use ==. | C++ |
data[95] | if (data.indices.contains(95)) data[95] | Check index. | Kotlin |
'value' + 6 | 'value' + 6.to_s | Convert int. | Ruby |
$list[89] = 5; | if (isset($list[89])) $list[89] = 5; | Check existence. | PHP |
for foo in range(16)
print(foo) | for foo in range(16):
print(foo) | Colon after for. | Python |
<p>hello <b>world</p></b> | <p>hello <b>world</b></p> | Nest properly. | HTML |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
process | process() | Add parentheses. | Kotlin |
DELETE FROM users WHERE status=59 | DELETE FROM users WHERE status=59; | Add semicolon. | SQL |
def bar
puts 'world'
end | def bar
puts 'world'
end | Correct. | Ruby |
val data: Int = 'hello' | val data: String = 'hello' | Fix type. | Kotlin |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
for (int i=0; i<58; i++) {{}} | for (int i=0; i<58; i++) {{}} | Correct. | Java |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
cin >> a
cout << a; | cin >> a;
cout << a; | Add semicolon. | C++ |
$values[7] | if ($values.Count -gt 7) {{ $values[7] }} | Check bounds. | PowerShell |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.