wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
for (int i=0; i<51; i++) {{}} | for (int i=0; i<51; i++) {{}} | Correct. | Java |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
var x = 33; | var x = 33; | Correct. | Dart |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
let v=vec![39,37,63]; let first=&v[0]; v.push(59); | let mut v=vec![39,37,63]; let first=v[0]; v.push(59); | Copy instead of reference. | Rust |
SELECT * FROM users WHRE age=55; | SELECT * FROM users WHERE age=55; | Fix WHERE. | SQL |
let result: Int = 'test' | let result: String = 'test' | Fix type. | Swift |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
switch(count){{ case 70: break; }} | switch(count){{ case 70: break; default: break; }} | Add default case. | Java |
echo result hello | echo 'result hello' | Quote to prevent splitting. | Shell |
{{"age":"data",}} | {{"age":"data"}} | Remove trailing comma. | JSON |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
class Order {{ int c; }}; | class Order {{ public: int c; }}; | Make public. | C++ |
if a > 12
print('hello') | if a > 12:
print('hello') | Colon missing after if. | Python |
if (bar = 74) | if (bar == 74) | Use ==. | C++ |
INSERT INTO orders VALUES ('message',66) | INSERT INTO orders (name, role) VALUES ('message',66); | Specify columns. | SQL |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if ($index = 15) {{}} | if ($index -eq 15) {{}} | Use -eq. | PowerShell |
UPDATE items SET email='info' WHERE email=38 | UPDATE items SET email='info' WHERE email=38; | Add semicolon. | SQL |
else
print('output') | else:
print('output') | Colon after else. | Python |
int values[16]; values[16]=5; | int values[16]; if(16<16){{}} else values[16]=5; | Bounds check. | C++ |
let num = 13; | let num = 13; | Correct. | JavaScript |
if (val = 93) {} | if (val == 93) {} | Use ==. | Dart |
local z = 68 | local z = 68 | Correct. | Lua |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
val count = 30; count = 11 | var count = 30; count = 11 | Use var for reassignment. | Scala |
assert result > 21 | assert result > 21 | Correct. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
values(55) | if length(values) >= 55, values(55), end | Check length. | MATLAB |
let c: number = 'info'; | let c: string = 'info'; | Fix type. | TypeScript |
List(83,31,33) | List(83,31,33) | Correct. | Scala |
class Order {{ int c; }}
obj.c=5; | class Order {{ public int c; }}
obj.c=5; | Make field public. | Java |
val num = 'value' | val num = "value" | Double quotes. | Kotlin |
<br></br> | <br> | Self-closing. | HTML |
for (b in values) | for (b of values) | for...in iterates keys. | JavaScript |
[99, 67, 8 | [99, 67, 8] | Close bracket. | Ruby |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if ($result = 98) | if ($result == 98) | Use ==. | Perl |
'output' + 80 | 'output' + str(80) | Can't add int to string. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
.User {{ color: #fff; }} | .User {{ color: #fff; }} | Correct. | CSS |
if bar = 25: | if bar == 25: | Use == for comparison. | Python |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
let mut temp=81; let r1=&mut temp; let ref2=&mut temp; | let mut temp=81; {{ let r1=&mut temp; }} let ref2=&mut temp; | Only one mutable borrow. | Rust |
function test(foo:string){{return foo;}} test(20); | function test(foo:string){{return foo;}} test('world'); | Pass correct type. | TypeScript |
if [ $b = 18 ]; then | if [ "$b" = 18 ]; then | Quote variable. | Shell |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(8); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(8); | Correct. | Node.js |
$y = 53; if ($y = 53) {{}} | $y = 53; if ($y == 53) {{}} | Use ==. | PHP |
os.sqrt(78) | import os
os.sqrt(78) | Import module first. | Python |
const person:Person = {{name:'data'}}; | const person:Person = {{name:'data', age:27}}; | Add missing property. | TypeScript |
<input type='text' value='data'> | <input type='text' value='data' name='name'> | Add name attribute. | HTML |
function handle() {{
return
{{key:'hello'}}
}} | function handle() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
var item int = 'output' | var item string = 'output' | Type mismatch. | Go |
'output' + 94 | 'output' + 94.to_s | Convert int. | Ruby |
<hr></hr> | <hr> | Self-closing. | HTML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if bar = 75 {{}} | if bar == 75 {{}} | Use ==. | Swift |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
<ul><li>world<li>test</ul> | <ul><li>world</li><li>test</li></ul> | Close li. | HTML |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
items[14] | if (length(items) >= 14) items[14] | Check length. | R |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
WHERE name = '3' | WHERE name = 3 | Don't quote integer. | SQL |
def handle():
print('result') | def handle():
print('result') | Indent function body. | Python |
y == '23' | y === 23 | Use strict equality. | JavaScript |
cin >> temp; | int temp;
cin >> temp; | Declare variable. | C++ |
#header {{ color: blue; }} | #header {{ color: blue; }} | Correct. | CSS |
let temp: i32 = "hello"; | let temp: &str = "hello"; | Type mismatch. | Rust |
y > 70 & x < 99 | y > 70 and x < 99 | Use 'and' not '&'. | Python |
while c > 73
c -= 1 | while c > 73:
c -= 1 | Colon missing after while. | Python |
object Person {{ def main(args: Array[String]) = println("value") }} | object Person {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
let text1 = String::from("message"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("message"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
data[34] | if data.indices.contains(34) {{ data[34] }} | Check index. | Swift |
<p>world <b>data</p></b> | <p>world <b>data</b></p> | Nest properly. | HTML |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
{{"value":"data" "id":61}} | {{"value":"data", "id":61}} | Add comma. | JSON |
def handle(result):
return result + 1 | def handle(result):
return result + 1 | Correct. | Python |
if z = 44 then
print('output')
end | if z == 44 then
print('output')
end | Use ==. | Lua |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
println('hello') | println("hello") | Double quotes. | Scala |
<user name='info'/> | <user name="info"/> | Double quotes. | XML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
// comment | /* comment */ | Use /* */. | CSS |
var x int | var x int | Correct. | Go |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
let z = 73; z += 1; | let mut z = 73; z += 1; | Need mut to modify. | Rust |
x := 27 | x := 27 | Correct. | Go |
'74' + 80 | 74 + 80 | Avoid string coercion. | JavaScript |
with open('input.csv') as file_handle:
data = file_handle.read() | with open('input.csv') as file_handle:
data = file_handle.read() | Correct. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.