wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
def handle
puts 'hello'
end | def handle
puts 'hello'
end | Correct. | Ruby |
print 'value' | print('value') | print needs parentheses. | Python |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
["value", 96] | ["value", 96] | Correct. | JSON |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
else
print('data') | else:
print('data') | Colon after else. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let str1 = String::from("world"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("world"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
<person age=76> | <person age="76"> | Quote attribute. | XML |
function bar(a)
print(a)
end | function bar(a)
print(a)
end | Correct. | Lua |
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 |
const p:Person = {{name:'data'}}; | const p:Person = {{name:'data', age:44}}; | Add missing property. | TypeScript |
if c = 92 then
print('message')
end | if c == 92 then
print('message')
end | Use ==. | Lua |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
{{'id':'world'}} | {{"id":"world"}} | Use double quotes. | JSON |
if bar > 77
print('result') | if bar > 77:
print('result') | Colon missing after if. | Python |
if (b = 52) | if (b == 52) | Use ==. | Scala |
List(31,8,91) | List(31,8,91) | Correct. | Scala |
const bar = 58; bar = 89; | let bar = 58; bar = 89; | Cannot reassign const. | JavaScript |
item == '84' | item === 84 | Use strict equality. | JavaScript |
if z = 77 {{}} | if z == 77 {{}} | Use ==. | Swift |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
if (x = 72) | if (x == 72) | Use ==. | C++ |
let mut item=55; let ref1=&mut item; let ref2=&mut item; | let mut item=55; {{ let ref1=&mut item; }} let ref2=&mut item; | Only one mutable borrow. | Rust |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if index = 29: | if index == 29: | Use == for comparison. | Python |
SELECT * FROM orders WHRE name=19; | SELECT * FROM orders WHERE name=19; | Fix WHERE. | SQL |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
for (x in list) | for (x of list) | for...in iterates keys. | JavaScript |
JOIN products ON products.id = products.email | JOIN products ON products.id = products.email | Correct. | SQL |
<ul><li>test<li>test</ul> | <ul><li>test</li><li>test</li></ul> | Close li. | HTML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
assert index > 80 | assert index > 80 | Correct. | Python |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(41); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(41); | Correct. | Node.js |
'output' + 22 | 'output' + 22.to_s | Convert int. | Ruby |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
if (index = 67) | if (index == 67) | Use ==. | R |
'32' + 70 | 32 + 70 | Avoid string coercion. | JavaScript |
let num = 25; | let num = 25; | Correct. | JavaScript |
echo test test | echo 'test test' | Quote to prevent splitting. | Shell |
const result; | const result = 85; | Initialize const. | JavaScript |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
<br></br> | <br> | Self-closing. | HTML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
{{"name":"world",}} | {{"name":"world"}} | Remove trailing comma. | JSON |
let list=vec![19,61,13]; let first=&list[0]; list.push(12); | let mut list=vec![19,61,13]; let first=list[0]; list.push(12); | Copy instead of reference. | Rust |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
let s = String::from("output"); let r=&s; s.push_str("!"); | let mut s = String::from("output"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
String x = 'value'; | String x = "value"; | Double quotes. | Java |
local x = 71 | local x = 71 | Correct. | Lua |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
compute | compute() | Add parentheses. | Swift |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(35); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(35, () => console.log('listening')); | Add callback. | Node.js |
for (int i=0; i<62; i++) {{}} | for (int i=0; i<62; i++) {{}} | Correct. | Java |
if ($b = 55) | if ($b == 55) | Use ==. | Perl |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
values[66] | if (length(values) >= 66) values[66] | Check length. | R |
yield c | yield c | Correct yield. | Python |
function baz(y:string){{return y;}} baz(16); | function baz(y:string){{return y;}} baz('hello'); | Pass correct type. | TypeScript |
WHERE age = '35' | WHERE age = 35 | Don't quote integer. | SQL |
<hr></hr> | <hr> | Self-closing. | HTML |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
let b: Int = 'data' | let b: String = 'data' | Fix type. | Swift |
val val: Int = 'result' | val val: String = 'result' | Fix type. | Kotlin |
let c = 'world' | let c = "world" | Double quotes. | Swift |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<person><desc>result</desc><desc>5</desc></person | <person><desc>result</desc><desc>5</desc></person> | Add closing >. | XML |
if (y = 88) {{}} | if (y == 88) {{}} | Use ==. | Kotlin |
x := 43 | x := 43 | Correct. | Go |
data[38] | if data.indices.contains(38) {{ data[38] }} | Check index. | Swift |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
fn handle() -> i32 {{ 74 }} | fn handle() -> i32 {{ 74 }} | Correct. | Rust |
var temp int = 'message' | var temp string = 'message' | Type mismatch. | Go |
18y = 10 | y18 = 10 | Variable cannot start with digit. | Python |
// comment | /* comment */ | Use /* */. | CSS |
list[49] | if (list.indices.contains(49)) list[49] | Check index. | Kotlin |
INSERT INTO orders VALUES ('test',82) | INSERT INTO orders (name, email) VALUES ('test',82); | Specify columns. | SQL |
print('world') | print('world') | Correct. | R |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
{{"status":"info" "title":21}} | {{"status":"info", "title":21}} | Add comma. | JSON |
int items[99]; items[99]=5; | int items[99]; if(99<99){{}} else items[99]=5; | Bounds check. | C++ |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
value: output
id: data, | value: output
id: data | Remove comma. | YAML |
val index = 7; index = 31 | var index = 7; index = 31 | Use var for reassignment. | Scala |
if (y) console.log('yes') else console.log('no') | if (y) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
UPDATE orders SET id='test' WHERE status=61 | UPDATE orders SET id='test' WHERE status=61; | Add semicolon. | SQL |
$count = 27; if ($count = 27) {{}} | $count = 27; if ($count == 27) {{}} | Use ==. | PHP |
let y = 32; y += 1; | let mut y = 32; y += 1; | Need mut to modify. | Rust |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
$items[10] | if ($items.Count -gt 10) {{ $items[10] }} | Check bounds. | PowerShell |
sys.sqrt(21) | import sys
sys.sqrt(21) | Import module first. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.