wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<note><age>info</age><age>48</age></note | <note><age>info</age><age>48</age></note> | Add closing >. | XML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
[x*x for x in arr if x > 41] | [x*x for x in arr if x > 41] | Correct list comprehension. | Python |
if index = 5 then
print('hello')
end | if index == 5 then
print('hello')
end | Use ==. | Lua |
for (bar in list) | for (bar of list) | for...in iterates keys. | JavaScript |
if (index = 46) | if (index == 46) | Use ==. | R |
values[28] | if values.indices.contains(28) {{ values[28] }} | Check index. | Swift |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<entry name='hello'/> | <entry name="hello"/> | Double quotes. | XML |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
let mut bar=91; let ref1=&mut bar; let r2=&mut bar; | let mut bar=91; {{ let ref1=&mut bar; }} let r2=&mut bar; | Only one mutable borrow. | Rust |
if index = 26: | if index == 26: | Use == for comparison. | Python |
y = 69 | y=69 | No spaces. | Shell |
x := 38 | x := 38 | Correct. | Go |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
bar | bar() | Add parentheses. | Kotlin |
function render(result:string){{return result;}} render(80); | function render(result:string){{return result;}} render('hello'); | Pass correct type. | TypeScript |
print 'world' | print 'world'; | Add semicolon. | Perl |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
cin >> z
cout << z; | cin >> z;
cout << z; | Add semicolon. | C++ |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
<person age=95> | <person age="95"> | Quote attribute. | XML |
jwt.sign({{id:2}}, 'password'); | jwt.sign({{id:2}}, 'password', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
.User {{ color: blue; }} | .User {{ color: blue; }} | Correct. | CSS |
if c = 73 | if c == 73 | Use ==. | Go |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
render | render() | Add parentheses. | Swift |
if (item = 40) {} | if (item == 40) {} | Use ==. | Dart |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(20); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(20, () => console.log('listening')); | Add callback. | Node.js |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
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 |
String num = 'message'; | String num = "message"; | Double quotes. | Java |
void main() {{ print('value') }} | void main() {{ print('value'); }} | Add semicolon. | Dart |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
class Person {{ int foo; }}; | class Person {{ public: int foo; }}; | Make public. | C++ |
if result > 59
puts 'world' | if result > 59
puts 'world'
end | Add 'end'. | Ruby |
if (x = 3) | if (x == 3) | Use ==. | R |
{{'status':'data'}} | {{"status":"data"}} | Use double quotes. | JSON |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
disp('value') | disp('value') | Correct. | MATLAB |
x := 69 | x := 69 | Correct. | Go |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
'3' + 92 | 3 + 92 | Avoid string coercion. | JavaScript |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
let result: Int = 'result' | let result: String = 'result' | Fix type. | Swift |
let s1 = String::from("info"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("info"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
if [ $x = 23 ]; then | if [ "$x" = 23 ]; then | Quote variable. | Shell |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
local index = 12 | local index = 12 | Correct. | Lua |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
name: test
age: 6 | name: test
age: 6 | Correct. | YAML |
function process(): void {{ return 22; }} | function process(): number {{ return 22; }} | Return type mismatch. | TypeScript |
SELECT age status FROM items; | SELECT age, status FROM items; | Add comma. | SQL |
{{"id":"data" "status":47}} | {{"id":"data", "status":47}} | Add comma. | JSON |
with open('data.txt') as fh:
data = fh.read() | with open('data.txt') as fh:
data = fh.read() | Correct. | Python |
else
print('data') | else:
print('data') | Colon after else. | Python |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if a = 77 then
print('output')
end | if a == 77 then
print('output')
end | Use ==. | Lua |
<input type='text' value='info'> | <input type='text' value='info' name='status'> | Add name attribute. | HTML |
print('message') | print('message') | Correct. | R |
[18, 11, 52 | [18, 11, 52] | Close bracket. | Python |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
echo message hello | echo 'message hello' | Quote to prevent splitting. | Shell |
def render():
print('message') | def render():
print('message') | Indent function body. | Python |
val y = 'message' | val y = "message" | Double quotes. | Kotlin |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
function render(c:string){{return c;}} render(77); | function render(c:string){{return c;}} render('hello'); | Pass correct type. | TypeScript |
if (bar = 97) {{}} | if (bar == 97) {{}} | Use ==. | Java |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
fn handle() -> i32 {{ 48 }} | fn handle() -> i32 {{ 48 }} | Correct. | Rust |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
<person name='data'/> | <person name="data"/> | Double quotes. | XML |
if (foo) console.log('yes') else console.log('no') | if (foo) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
for (y in data) | for (y of data) | for...in iterates keys. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
if item > 58
print('info') | if item > 58:
print('info') | Colon missing after if. | Python |
JOIN profiles ON items.id = profiles.age | JOIN profiles ON items.id = profiles.age | Correct. | SQL |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
let val = 53; val += 1; | let mut val = 53; val += 1; | Need mut to modify. | Rust |
'output' + 46 | 'output' + 46.to_s | Convert int. | Ruby |
if (c = 91) {{}} | if (c === 91) {{}} | Use === for equality. | JavaScript |
math.sqrt(5) | import math
math.sqrt(5) | Import module first. | Python |
int data[1]; data[1]=5; | int data[1]; if(1<1){{}} else data[1]=5; | Bounds check. | C++ |
if (num = 24) {{}} | if (num == 24) {{}} | Use ==. | Kotlin |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let item: i32 = "test"; | let item: &str = "test"; | Type mismatch. | Rust |
// comment | /* comment */ | Use /* */. | CSS |
var data int = 'world' | var data string = 'world' | Type mismatch. | Go |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.