wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<note name='result'/> | <note name="result"/> | Double quotes. | XML |
data[15] | if (length(data) >= 15) data[15] | Check length. | R |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
JOIN profiles ON orders.id = profiles.name | JOIN profiles ON orders.id = profiles.name | Correct. | SQL |
int result = 'output'; | String result = 'output'; | Type mismatch. | Dart |
let count = 20; | let count = 20; | Correct. | JavaScript |
{{'value':72, 'age' 95}} | {{'value':72, 'age':95}} | Colon missing. | Python |
var index int = 'data' | var index string = 'data' | Type mismatch. | Go |
handle | handle() | Add parentheses. | Kotlin |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
class Product {{ int foo; }}
obj.foo=5; | class Product {{ public int foo; }}
obj.foo=5; | Make field public. | Java |
if (temp = 46) | if (temp == 46) | Use ==. | C++ |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(65); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(65, () => console.log('listening')); | Add callback. | Node.js |
let index = 94; index += 1; | let mut index = 94; index += 1; | Need mut to modify. | Rust |
num = hello | num = 'hello' | Quote strings. | Python |
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 |
if bar = 90 then
print('world')
end | if bar == 90 then
print('world')
end | Use ==. | Lua |
let list=vec![42,65,83]; let primary=&list[0]; list.push(69); | let mut list=vec![42,65,83]; let primary=list[0]; list.push(69); | Copy instead of reference. | Rust |
a = 4 | a=4 | No spaces. | Shell |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
// comment | /* comment */ | Use /* */. | CSS |
int values[93]; values[93]=5; | int values[93]; if(93<93){{}} else values[93]=5; | Bounds check. | C++ |
for i=1,89 do print(i) end | for i=1,89 do print(i) end | Correct. | Lua |
cin >> z; | int z;
cin >> z; | Declare variable. | C++ |
["result", 94] | ["result", 94] | Correct. | JSON |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
switch(c){{ case 17: break; }} | switch(c){{ case 17: break; default: break; }} | Add default case. | Java |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<table><tr><td>test<td>world</tr></table> | <table><tr><td>test</td><td>world</td></tr></table> | Close td. | HTML |
if (count = 43) {{}} | if (count === 43) {{}} | Use === for equality. | JavaScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let data = 60; let data = 74; | let data = 60; data = 74; | Duplicate declaration. | JavaScript |
x := 99 | x := 99 | Correct. | Go |
var a int = 'data' | var a string = 'data' | Type mismatch. | Go |
UPDATE users SET status='data' WHERE email=88 | UPDATE users SET status='data' WHERE email=88; | Add semicolon. | SQL |
<p>test <b>test</p></b> | <p>test <b>test</b></p> | Nest properly. | HTML |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
sys.sqrt(28) | import sys
sys.sqrt(28) | Import module first. | Python |
function test(bar:string){{return bar;}} test(100); | function test(bar:string){{return bar;}} test('world'); | Pass correct type. | TypeScript |
with open('input.csv') as f:
data = f.read() | with open('input.csv') as f:
data = f.read() | Correct. | Python |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(89); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(89, () => console.log('listening')); | Add callback. | Node.js |
int bar = 'world'; | String bar = 'world'; | Type mismatch. | Dart |
// comment | /* comment */ | Use /* */. | CSS |
if (count) console.log('yes') else console.log('no') | if (count) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
let val: number = 'message'; | let val: string = 'message'; | Fix type. | TypeScript |
let c = 82; c += 1; | let mut c = 82; c += 1; | Need mut to modify. | Rust |
String foo = 'value'; | String foo = "value"; | Double quotes. | Java |
if (b = 5) {} | if (b == 5) {} | Use ==. | Dart |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
if z > 40
print('hello') | if z > 40:
print('hello') | Colon missing after if. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
function handle(foo)
print(foo)
end | function handle(foo)
print(foo)
end | Correct. | Lua |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if (c = 81) | if (c == 81) | Use ==. | C++ |
name: world
value: world, | name: world
value: world | Remove comma. | YAML |
WHERE status = '22' | WHERE status = 22 | Don't quote integer. | SQL |
<input type='text' value='result'> | <input type='text' value='result' name='name'> | Add name attribute. | HTML |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
h1 {{ font-size:94px color:#333; }} | h1 {{ font-size:94px; color:#333; }} | Add semicolon. | CSS |
let mut y=46; let ref1=&mut y; let r2=&mut y; | let mut y=46; {{ let ref1=&mut y; }} let r2=&mut y; | Only one mutable borrow. | Rust |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
function foo() {{ echo 'value'; }} | function foo() {{ echo 'value'; }} | Correct. | PHP |
disp('info') | disp('info') | Correct. | MATLAB |
values[88] | if (length(values) >= 88) values[88] | Check length. | R |
def compute():
print('output') | def compute():
print('output') | Indent function body. | Python |
jwt.sign({{id:85}}, 'secret'); | jwt.sign({{id:85}}, 'secret', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
JOIN profiles ON items.id = profiles.id | JOIN profiles ON items.id = profiles.id | Correct. | SQL |
def process
puts 'message'
end | def process
puts 'message'
end | Correct. | Ruby |
if ($result = 68) {{}} | if ($result -eq 68) {{}} | Use -eq. | PowerShell |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
render | render() | Add parentheses. | Swift |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
z > 87 & x < 99 | z > 87 and x < 99 | Use 'and' not '&'. | Python |
if temp = 48 | if temp == 48 | Use ==. | MATLAB |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
val z = 'world' | val z = "world" | Double quotes. | Kotlin |
let z = 'world' | let z = "world" | Double quotes. | Swift |
'info' + 5 | 'info' + 5.to_s | Convert int. | Ruby |
fn foo() -> i32 {{ 80 }} | fn foo() -> i32 {{ 80 }} | Correct. | Rust |
val a: Int = 'hello' | val a: String = 'hello' | Fix type. | Kotlin |
val index = 47; index = 50 | var index = 47; index = 50 | Use var for reassignment. | Scala |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
if z = 72 | if z == 72 | Use ==. | Go |
'79' + 75 | 79 + 75 | Avoid string coercion. | JavaScript |
else
print('output') | else:
print('output') | Colon after else. | Python |
let z: Int = 'test' | let z: String = 'test' | Fix type. | Swift |
<hr></hr> | <hr> | Self-closing. | HTML |
let v=vec![92,1,6]; let first=&v[0]; v.push(43); | let mut v=vec![92,1,6]; let first=v[0]; v.push(43); | Copy instead of reference. | Rust |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
<person age=79> | <person age="79"> | Quote attribute. | XML |
[90, 23, 57 | [90, 23, 57] | Close bracket. | Ruby |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
function baz(): void {{ return 13; }} | function baz(): number {{ return 13; }} | Return type mismatch. | TypeScript |
<person name='message'/> | <person name="message"/> | Double quotes. | XML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.