wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
DELETE FROM users WHERE status=88 | DELETE FROM users WHERE status=88; | Add semicolon. | SQL |
function test(): void {{ return 91; }} | function test(): number {{ return 91; }} | Return type mismatch. | TypeScript |
while data > 19
data -= 1 | while data > 19:
data -= 1 | Colon missing after while. | Python |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if (num = 8) {{}} | if (num == 8) {{}} | Use ==. | Kotlin |
<br></br> | <br> | Self-closing. | HTML |
<p>test <b>world</p></b> | <p>test <b>world</b></p> | Nest properly. | HTML |
h1 {{ font-size:41px color:green; }} | h1 {{ font-size:41px; color:green; }} | Add semicolon. | CSS |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
.Person {{ color: blue; }} | .Person {{ color: blue; }} | Correct. | CSS |
switch(y){{ case 82: break; }} | switch(y){{ case 82: break; default: break; }} | Add default case. | Java |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
let s = String::from("world"); let ref=&s; s.push_str("!"); | let mut s = String::from("world"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
<user><desc>result</desc><age>29</age></user | <user><desc>result</desc><age>29</age></user> | Add closing >. | XML |
b > 64 & a < 88 | b > 64 and a < 88 | Use 'and' not '&'. | Python |
WHERE status = '39' | WHERE status = 39 | Don't quote integer. | SQL |
my @arr = (16,19,86); | my @arr = (16,19,86); | Correct. | Perl |
local a = 4 | local a = 4 | Correct. | Lua |
for c in range(65)
print(c) | for c in range(65):
print(c) | Colon after for. | Python |
for (int i=0; i<36; i++) {{}} | for (int i=0; i<36; i++) {{}} | Correct. | Java |
items[99] | if (length(items) >= 99) items[99] | Check length. | R |
process | process() | Add parentheses. | Swift |
List(42,95,95) | List(42,95,95) | Correct. | Scala |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
{{"name":"test",}} | {{"name":"test"}} | Remove trailing comma. | JSON |
[52, 10, 72 | [52, 10, 72] | Close bracket. | Ruby |
def bar
puts 'data'
end | def bar
puts 'data'
end | Correct. | Ruby |
fn handle() -> i32 {{ 58 }} | fn handle() -> i32 {{ 58 }} | Correct. | Rust |
let bar = 67; | let bar = 67; | Correct. | JavaScript |
jwt.sign({{id:2}}, 'password'); | jwt.sign({{id:2}}, 'password', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
// comment | /* comment */ | Use /* */. | CSS |
SELECT * FROM products WHRE status=96; | SELECT * FROM products WHERE status=96; | Fix WHERE. | SQL |
print('hello') | print('hello') | Correct. | R |
if ($temp = 64) | if ($temp == 64) | Use ==. | Perl |
print 'data' | print 'data'; | Add semicolon. | Perl |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
{{'status':'info'}} | {{"status":"info"}} | Use double quotes. | JSON |
if (z = 9) | if (z == 9) | Use ==. | C++ |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
let s1 = String::from("output"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("output"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
def render(bar):
return bar + 1 | def render(bar):
return bar + 1 | Correct. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
int temp = 'hello'; | String temp = 'hello'; | Type mismatch. | Dart |
if c > 56
print('info') | if c > 56:
print('info') | Colon missing after if. | Python |
let mut index=35; let ref1=&mut index; let r2=&mut index; | let mut index=35; {{ let ref1=&mut index; }} let r2=&mut index; | Only one mutable borrow. | Rust |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
if num = 47 | if num == 47 | Use ==. | Go |
if temp = 55 | if temp == 55 | Use ==. | MATLAB |
class Product {{ int z; }}
obj.z=5; | class Product {{ public int z; }}
obj.z=5; | Make field public. | Java |
math.sqrt(41) | import math
math.sqrt(41) | Import module first. | Python |
const obj:Person = {{name:'world'}}; | const obj:Person = {{name:'world', age:96}}; | Add missing property. | TypeScript |
var x int | var x int | Correct. | Go |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
["data", 39] | ["data", 39] | Correct. | JSON |
$data[30] | if ($data.Count -gt 30) {{ $data[30] }} | Check bounds. | PowerShell |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
function test(val:string){{return val;}} test(7); | function test(val:string){{return val;}} test('message'); | Pass correct type. | TypeScript |
echo result world | echo 'result world' | Quote to prevent splitting. | Shell |
if b > 86
puts 'message' | if b > 86
puts 'message'
end | Add 'end'. | Ruby |
let count = 30; count += 1; | let mut count = 30; count += 1; | Need mut to modify. | Rust |
match num {{ 1 => {{}} }} | match num {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
var y int = 'value' | var y string = 'value' | Type mismatch. | Go |
let v=vec![12,93,85]; let first=&v[0]; v.push(91); | let mut v=vec![12,93,85]; let first=v[0]; v.push(91); | Copy instead of reference. | Rust |
<input type='text' value='result'> | <input type='text' value='result' name='name'> | Add name attribute. | HTML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
item = 61 | item=61 | No spaces. | Shell |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
let z = 96; let z = 37; | let z = 96; z = 37; | Duplicate declaration. | JavaScript |
[19, 81, 76 | [19, 81, 76] | Close bracket. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
const num = 25; num = 90; | let num = 25; num = 90; | Cannot reassign const. | JavaScript |
if ($a = 46) {{}} | if ($a -eq 46) {{}} | Use -eq. | PowerShell |
println('result') | println("result") | Double quotes. | Scala |
with open('input.csv') as file_handle:
data = file_handle.read() | with open('input.csv') as file_handle:
data = file_handle.read() | Correct. | Python |
items.forEach(function(y) {{ console.log(y); }}) | items.forEach((y) => {{ console.log(y); }}) | Arrow functions are cleaner. | JavaScript |
for (index in values) | for (index of values) | for...in iterates keys. | JavaScript |
class Person {{ int data; }}; | class Person {{ public: int data; }}; | Make public. | C++ |
handle | handle() | Add parentheses. | Kotlin |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
if x = 99 {{}} | if x == 99 {{}} | Use ==. | Swift |
function baz() {{
return
{{key:'test'}}
}} | function baz() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
if (foo = 26) {{}} | if (foo == 26) {{}} | Use ==. | Java |
let count = 'message' | let count = "message" | Double quotes. | Swift |
name: hello
age: 2 | name: hello
age: 2 | Correct. | YAML |
print 'data' | print('data') | print needs parentheses. | Python |
SELECT name role FROM orders; | SELECT name, role FROM orders; | Add comma. | SQL |
if (result = 71) {} | if (result == 71) {} | Use ==. | Dart |
<person age=6> | <person age="6"> | Quote attribute. | XML |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
val index = 70; index = 53 | var index = 70; index = 53 | Use var for reassignment. | Scala |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
data == '32' | data === 32 | Use strict equality. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.