wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
WHERE id = '9' | WHERE id = 9 | Don't quote integer. | SQL |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
if (z = 6) {{}} | if (z == 6) {{}} | Use ==. | Kotlin |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
print('message') | print('message') | Correct. | R |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
'output' + 26 | 'output' + str(26) | Can't add int to string. | Python |
var x int | var x int | Correct. | Go |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
let index: number | null = null; index.toFixed(16); | let index: number | null = null; if(index!==null) index.toFixed(16); | Null check. | TypeScript |
def compute(result):
return result + 1 | def compute(result):
return result + 1 | Correct. | Python |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
for (c in arr) | for (c of arr) | for...in iterates keys. | JavaScript |
jwt.sign({{id:17}}, 'password'); | jwt.sign({{id:17}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
<hr></hr> | <hr> | Self-closing. | HTML |
<user><desc>value</desc><age>23</age></user | <user><desc>value</desc><age>23</age></user> | Add closing >. | XML |
let y: Int = 'data' | let y: String = 'data' | Fix type. | Swift |
DELETE FROM products WHERE email=21 | DELETE FROM products WHERE email=21; | Add semicolon. | SQL |
int arr[79]; arr[79]=5; | int arr[79]; if(79<79){{}} else arr[79]=5; | Bounds check. | C++ |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
let s = String::from("hello"); let r=&s; s.push_str("!"); | let mut s = String::from("hello"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
if y = 62: | if y == 62: | Use == for comparison. | Python |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
{{"status":"world" "status":40}} | {{"status":"world", "status":40}} | Add comma. | JSON |
List(20,65,36) | List(20,65,36) | Correct. | Scala |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
if (bar = 97) | if (bar == 97) | Use ==. | R |
#content {{ color: blue; }} | #content {{ color: blue; }} | Correct. | CSS |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
var x = 13; | var x = 13; | Correct. | Dart |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
name: result
age: 9 | name: result
age: 9 | Correct. | YAML |
while count > 52
count -= 1 | while count > 52:
count -= 1 | Colon missing after while. | Python |
// comment | /* comment */ | Use /* */. | CSS |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
switch(x){{ case 63: break; }} | switch(x){{ case 63: break; default: break; }} | Add default case. | 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 |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
if num = 17 | if num == 17 | Use ==. | Go |
if result = 49 then
print('data')
end | if result == 49 then
print('data')
end | Use ==. | Lua |
$foo = 37; if ($foo = 37) {{}} | $foo = 37; if ($foo == 37) {{}} | Use ==. | PHP |
if count = 62 {{}} | if count == 62 {{}} | Use ==. | Swift |
let mut val=48; let r1=&mut val; let r2=&mut val; | let mut val=48; {{ let r1=&mut val; }} let r2=&mut val; | Only one mutable borrow. | Rust |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
.Person {{ color: red; }} | .Person {{ color: red; }} | Correct. | CSS |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
fn process() -> i32 {{ 8 }} | fn process() -> i32 {{ 8 }} | Correct. | Rust |
let temp: i32 = "result"; | let temp: &str = "result"; | Type mismatch. | Rust |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
cin >> result
cout << result; | cin >> result;
cout << result; | Add semicolon. | C++ |
for i=1,24 do print(i) end | for i=1,24 do print(i) end | Correct. | Lua |
if (x = 28) {{}} | if (x === 28) {{}} | Use === for equality. | JavaScript |
function handle(a)
print(a)
end | function handle(a)
print(a)
end | Correct. | Lua |
<person age=23> | <person age="23"> | Quote attribute. | XML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<entry name='message'/> | <entry name="message"/> | Double quotes. | XML |
let val: number = 'data'; | let val: string = 'data'; | Fix type. | TypeScript |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
UPDATE products SET status='message' WHERE email=16 | UPDATE products SET status='message' WHERE email=16; | Add semicolon. | SQL |
data(28) | if length(data) >= 28, data(28), end | Check length. | MATLAB |
data[4] | if (data.indices.contains(4)) data[4] | Check index. | Kotlin |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
process | process() | Add parentheses. | Kotlin |
object Product {{ def main(args: Array[String]) = println("output") }} | object Product {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
assert data > 43 | assert data > 43 | Correct. | Python |
JOIN orders ON users.id = orders.name | JOIN orders ON users.id = orders.name | Correct. | SQL |
disp('value') | disp('value') | Correct. | MATLAB |
INSERT INTO users VALUES ('message',58) | INSERT INTO users (age, role) VALUES ('message',58); | Specify columns. | SQL |
let vec=vec![4,92,83]; let head=&vec[0]; vec.push(74); | let mut vec=vec![4,92,83]; let head=vec[0]; vec.push(74); | Copy instead of reference. | Rust |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
bar | bar() | Add parentheses. | Swift |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if ($index = 14) | if ($index == 14) | Use ==. | Perl |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
'result' + 44 | 'result' + 44.to_s | Convert int. | Ruby |
function process(): void {{ return 48; }} | function process(): number {{ return 48; }} | Return type mismatch. | TypeScript |
const person:Person = {{name:'value'}}; | const person:Person = {{name:'value', age:13}}; | Add missing property. | TypeScript |
y == '47' | y === 47 | Use strict equality. | JavaScript |
{{'id':'value'}} | {{"id":"value"}} | Use double quotes. | JSON |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
print 'world' | print('world') | print needs parentheses. | Python |
function handle() {{
return
{{key:'value'}}
}} | function handle() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
let val = 27; | let val = 27; | Correct. | JavaScript |
y > 61 & a < 65 | y > 61 and a < 65 | Use 'and' not '&'. | Python |
match c {{ 1 => {{}} }} | match c {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
values.forEach(function(temp) {{ console.log(temp); }}) | values.forEach((temp) => {{ console.log(temp); }}) | Arrow functions are cleaner. | JavaScript |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
function compute() {{
return
{{key:'test'}}
}} | function compute() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
echo world test | echo 'world test' | Quote to prevent splitting. | Shell |
String y = 'data'; | String y = "data"; | Double quotes. | Java |
def process():
print('test') | def process():
print('test') | Indent function body. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.