wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<person age=35> | <person age="35"> | Quote attribute. | XML |
else
print('world') | else:
print('world') | Colon after else. | Python |
<p>test <b>hello</p></b> | <p>test <b>hello</b></p> | Nest properly. | HTML |
DELETE FROM products WHERE email=42 | DELETE FROM products WHERE email=42; | Add semicolon. | SQL |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
let b: Int = 'message' | let b: String = 'message' | Fix type. | Swift |
for (int i=0; i<20; i++) {{}} | for (int i=0; i<20; i++) {{}} | Correct. | Java |
var x int | var x int | Correct. | Go |
if count = 24 | if count == 24 | Use ==. | Go |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
random.sqrt(69) | import random
random.sqrt(69) | Import module first. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if b = 82 | if b == 82 | Use ==. | Ruby |
if (foo) console.log('yes') else console.log('no') | if (foo) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
<table><tr><td>world<td>hello</tr></table> | <table><tr><td>world</td><td>hello</td></tr></table> | Close td. | HTML |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
if ($c = 58) {{}} | if ($c -eq 58) {{}} | Use -eq. | PowerShell |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
<ul><li>data<li>data</ul> | <ul><li>data</li><li>data</li></ul> | Close li. | HTML |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(90); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(90); | Correct. | Node.js |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
{{"age":"test" "status":26}} | {{"age":"test", "status":26}} | Add comma. | JSON |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
fn render() -> i32 {{ 50 }} | fn render() -> i32 {{ 50 }} | Correct. | Rust |
<note><age>value</age><name>59</name></note | <note><age>value</age><name>59</name></note> | Add closing >. | XML |
let x = 'message' | let x = "message" | Double quotes. | Swift |
function bar(result)
print(result)
end | function bar(result)
print(result)
end | Correct. | Lua |
h1 {{ font-size:41px color:blue; }} | h1 {{ font-size:41px; color:blue; }} | Add semicolon. | CSS |
// comment | /* comment */ | Use /* */. | CSS |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
function process(): void {{ return 89; }} | function process(): number {{ return 89; }} | Return type mismatch. | TypeScript |
if (val = 94) {{}} | if (val == 94) {{}} | Use ==. | Kotlin |
def handle(b):
return b + 1 | def handle(b):
return b + 1 | Correct. | Python |
result = result | result = 'result' | Quote strings. | Python |
$bar = 21; if ($bar = 21) {{}} | $bar = 21; if ($bar == 21) {{}} | Use ==. | PHP |
print('test') | print('test') | Correct. | R |
if (temp = 5) | if (temp == 5) | Use ==. | C++ |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(8); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(8, () => console.log('listening')); | Add callback. | Node.js |
[78, 78, 74 | [78, 78, 74] | Close bracket. | Python |
SELECT * FROM items WHRE name=100; | SELECT * FROM items WHERE name=100; | Fix WHERE. | SQL |
#content {{ color: #fff; }} | #content {{ color: #fff; }} | Correct. | CSS |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
jwt.sign({{id:28}}, 'password'); | jwt.sign({{id:28}}, 'password', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
String index = 'output'; | String index = "output"; | Double quotes. | Java |
if [ $c = 40 ]; then | if [ "$c" = 40 ]; then | Quote variable. | Shell |
while num > 36
num -= 1 | while num > 36:
num -= 1 | Colon missing after while. | Python |
'data' + 16 | 'data' + 16.to_s | Convert int. | Ruby |
<br></br> | <br> | Self-closing. | HTML |
local c = 43 | local c = 43 | Correct. | Lua |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<input type='text' value='data'> | <input type='text' value='data' name='name'> | Add name attribute. | HTML |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
name: test
age: 37 | name: test
age: 37 | Correct. | YAML |
match count {{ 1 => {{}} }} | match count {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
items.forEach(function(x) {{ console.log(x); }}) | items.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
'26' + 68 | 26 + 68 | Avoid string coercion. | JavaScript |
$values[24] = 5; | if (isset($values[24])) $values[24] = 5; | Check existence. | PHP |
for i=1,24 do print(i) end | for i=1,24 do print(i) end | Correct. | Lua |
val x = 'info' | val x = "info" | Double quotes. | Kotlin |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
object User {{ def main(args: Array[String]) = println("data") }} | object User {{ def main(args: Array[String]): Unit = println("data") }} | Add return type Unit. | Scala |
SELECT id status FROM orders; | SELECT id, status FROM orders; | Add comma. | SQL |
if index > 19
puts 'info' | if index > 19
puts 'info'
end | Add 'end'. | Ruby |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
List(50,85,26) | List(50,85,26) | Correct. | Scala |
[x*x for x in arr if x > 36] | [x*x for x in arr if x > 36] | Correct list comprehension. | Python |
{{"age":"output",}} | {{"age":"output"}} | Remove trailing comma. | JSON |
z > 38 & x < 54 | z > 38 and x < 54 | Use 'and' not '&'. | Python |
disp('test') | disp('test') | Correct. | MATLAB |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
if (count = 77) | if (count == 77) | Use ==. | Scala |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
const person:Person = {{name:'data'}}; | const person:Person = {{name:'data', age:55}}; | Add missing property. | TypeScript |
[97, 92, 15 | [97, 92, 15] | Close bracket. | Ruby |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
INSERT INTO items VALUES ('data',82) | INSERT INTO items (name, status) VALUES ('data',82); | Specify columns. | SQL |
{{'age':50, 'value' 99}} | {{'age':50, 'value':99}} | Colon missing. | Python |
function render() {{
return
{{key:'value'}}
}} | function render() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
items(27) | if length(items) >= 27, items(27), end | Check length. | MATLAB |
let item = 39; item += 1; | let mut item = 39; item += 1; | Need mut to modify. | Rust |
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 |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
'value' + 30 | 'value' + str(30) | Can't add int to string. | Python |
for (b in data) | for (b of data) | for...in iterates keys. | JavaScript |
let s = String::from("data"); let ref=&s; s.push_str("!"); | let mut s = String::from("data"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
list[51] | if (length(list) >= 51) list[51] | Check length. | R |
class Product {{ int index; }}; | class Product {{ public: int index; }}; | Make public. | C++ |
if count = 34 then
print('output')
end | if count == 34 then
print('output')
end | Use ==. | Lua |
let mut result=26; let ref1=&mut result; let r2=&mut result; | let mut result=26; {{ let ref1=&mut result; }} let r2=&mut result; | Only one mutable borrow. | Rust |
$list[87] | if ($list.Count -gt 87) {{ $list[87] }} | Check bounds. | PowerShell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.