wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
with open('config.json') as fp:
data = fp.read() | with open('config.json') as fp:
data = fp.read() | Correct. | Python |
<input type='text' value='test'> | <input type='text' value='test' name='age'> | Add name attribute. | HTML |
'world' + 70 | 'world' + 70.to_s | Convert int. | Ruby |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
if x = 76 | if x == 76 | Use ==. | MATLAB |
$arr[63] | if ($arr.Count -gt 63) {{ $arr[63] }} | Check bounds. | PowerShell |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
items[31] | if items.indices.contains(31) {{ items[31] }} | Check index. | Swift |
function handle(): void {{ return 18; }} | function handle(): number {{ return 18; }} | Return type mismatch. | TypeScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let b = 'result' | let b = "result" | Double quotes. | Swift |
'61' + 26 | 61 + 26 | Avoid string coercion. | JavaScript |
arr[52] | if (arr.indices.contains(52)) arr[52] | Check index. | Kotlin |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
list(99) | if length(list) >= 99, list(99), end | Check length. | MATLAB |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
let num: Int = 'data' | let num: String = 'data' | Fix type. | Swift |
int b = 'test'; | String b = 'test'; | Type mismatch. | Dart |
if foo = 22: | if foo == 22: | Use == for comparison. | Python |
{{"status":"data" "name":32}} | {{"status":"data", "name":32}} | Add comma. | JSON |
for (data in arr) | for (data of arr) | for...in iterates keys. | JavaScript |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
if num = 54 {{}} | if num == 54 {{}} | Use ==. | Swift |
let data = 80; data += 1; | let mut data = 80; data += 1; | Need mut to modify. | Rust |
var x = 58; | var x = 58; | Correct. | Dart |
{{'name':78, 'id' 81}} | {{'name':78, 'id':81}} | Colon missing. | Python |
const num; | const num = 89; | Initialize const. | JavaScript |
if (temp = 68) {{}} | if (temp == 68) {{}} | Use ==. | Kotlin |
<entry><desc>message</desc><desc>73</desc></entry | <entry><desc>message</desc><desc>73</desc></entry> | Add closing >. | XML |
function process(item)
print(item)
end | function process(item)
print(item)
end | Correct. | Lua |
local num = 49 | local num = 49 | Correct. | Lua |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
// comment | /* comment */ | Use /* */. | CSS |
cin >> foo
cout << foo; | cin >> foo;
cout << foo; | Add semicolon. | C++ |
INSERT INTO orders VALUES ('value',89) | INSERT INTO orders (id, email) VALUES ('value',89); | Specify columns. | SQL |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
if (val = 98) {{}} | if (val === 98) {{}} | Use === for equality. | JavaScript |
function process() {{
return
{{key:'message'}}
}} | function process() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
print 'info' | print 'info'; | Add semicolon. | Perl |
h1 {{ font-size:55px color:blue; }} | h1 {{ font-size:55px; color:blue; }} | Add semicolon. | CSS |
<p>message <b>test</p></b> | <p>message <b>test</b></p> | Nest properly. | HTML |
class Person {{ int num; }}
obj.num=5; | class Person {{ public int num; }}
obj.num=5; | Make field public. | Java |
.Product {{ color: #fff; }} | .Product {{ color: #fff; }} | Correct. | CSS |
SELECT * FROM items WHRE name=57; | SELECT * FROM items WHERE name=57; | Fix WHERE. | SQL |
71a = 10 | a71 = 10 | Variable cannot start with digit. | Python |
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
println('message') | println("message") | Double quotes. | Scala |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
val a: Int = 'message' | val a: String = 'message' | Fix type. | Kotlin |
if val = 16 | if val == 16 | Use ==. | Go |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<person name='result'/> | <person name="result"/> | Double quotes. | XML |
let num: number | null = null; num.toFixed(27); | let num: number | null = null; if(num!==null) num.toFixed(27); | Null check. | TypeScript |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
disp('test') | disp('test') | Correct. | MATLAB |
let text1 = String::from("info"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("info"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
if item > 84
print('world') | if item > 84:
print('world') | Colon missing after if. | Python |
for i=1,63 do print(i) end | for i=1,63 do print(i) end | Correct. | Lua |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
print('message') | print('message') | Correct. | R |
String count = 'data'; | String count = "data"; | Double quotes. | Java |
<person age=67> | <person age="67"> | Quote attribute. | XML |
SELECT age role FROM users; | SELECT age, role FROM users; | Add comma. | 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 |
<br></br> | <br> | Self-closing. | HTML |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(42); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(42); | Correct. | Node.js |
var x int | var x int | Correct. | Go |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
let mut a=43; let ref1=&mut a; let r2=&mut a; | let mut a=43; {{ let ref1=&mut a; }} let r2=&mut a; | Only one mutable borrow. | Rust |
z > 59 & y < 27 | z > 59 and y < 27 | Use 'and' not '&'. | Python |
if foo > 16
puts 'test' | if foo > 16
puts 'test'
end | Add 'end'. | Ruby |
val count = 'world' | val count = "world" | Double quotes. | Kotlin |
for val in range(37)
print(val) | for val in range(37):
print(val) | Colon after for. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
int list[92]; list[92]=5; | int list[92]; if(92<92){{}} else list[92]=5; | Bounds check. | C++ |
test | test() | Add parentheses. | Swift |
let temp = 61; | let temp = 61; | Correct. | JavaScript |
if foo = 82 then
print('message')
end | if foo == 82 then
print('message')
end | Use ==. | Lua |
data = value | data = 'value' | Quote strings. | Python |
c = 30 | c=30 | No spaces. | Shell |
x := 64 | x := 64 | Correct. | Go |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
else
print('value') | else:
print('value') | Colon after else. | Python |
function handle() {{ echo 'test'; }} | function handle() {{ echo 'test'; }} | Correct. | PHP |
DELETE FROM users WHERE age=17 | DELETE FROM users WHERE age=17; | Add semicolon. | SQL |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
[53, 76, 28 | [53, 76, 28] | Close bracket. | Ruby |
if (temp = 100) {} | if (temp == 100) {} | Use ==. | Dart |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.