wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
def handle():
print('output') | def handle():
print('output') | Indent function body. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
let b: number | null = null; b.toFixed(85); | let b: number | null = null; if(b!==null) b.toFixed(85); | Null check. | TypeScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
if (val = 76) {{}} | if (val == 76) {{}} | Use ==. | Java |
function baz() {{
return
{{key:'world'}}
}} | function baz() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
if ($index = 56) | if ($index == 56) | Use ==. | Perl |
val bar: Int = 'info' | val bar: String = 'info' | Fix type. | Kotlin |
{{"id":"world" "value":93}} | {{"id":"world", "value":93}} | Add comma. | JSON |
<p>data <b>world</p></b> | <p>data <b>world</b></p> | Nest properly. | HTML |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
json.sqrt(83) | import json
json.sqrt(83) | Import module first. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
for (int i=0; i<4; i++) {{}} | for (int i=0; i<4; i++) {{}} | Correct. | Java |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if z = 24 {{}} | if z == 24 {{}} | Use ==. | Swift |
else
print('data') | else:
print('data') | Colon after else. | Python |
const temp = 4; temp = 50; | let temp = 4; temp = 50; | Cannot reassign const. | JavaScript |
'info' + 62 | 'info' + 62.to_s | Convert int. | Ruby |
local c = 84 | local c = 84 | Correct. | Lua |
switch(z){{ case 50: break; }} | switch(z){{ case 50: break; default: break; }} | Add default case. | Java |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
List(75,2,21) | List(75,2,21) | Correct. | Scala |
let s = String::from("data"); let borrow=&s; s.push_str("!"); | let mut s = String::from("data"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
title: info
title: world, | title: info
title: world | Remove comma. | YAML |
with open('config.json') as f:
data = f.read() | with open('config.json') as f:
data = f.read() | Correct. | Python |
{{"status":"info" "id":45}} | {{"status":"info", "id":45}} | Add comma. | JSON |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if (data = 84) | if (data == 84) | Use ==. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if c = 38 | if c == 38 | Use ==. | MATLAB |
{{'id':'result'}} | {{"id":"result"}} | Use double quotes. | JSON |
{{"value":"info",}} | {{"value":"info"}} | Remove trailing comma. | JSON |
if temp > 27
puts 'value' | if temp > 27
puts 'value'
end | Add 'end'. | Ruby |
if index = 19 | if index == 19 | Use ==. | Ruby |
if (index = 7) | if (index == 7) | Use ==. | Scala |
render | render() | Add parentheses. | Swift |
var b int = 'message' | var b string = 'message' | Type mismatch. | Go |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
const b; | const b = 15; | Initialize const. | JavaScript |
if x = 40 | if x == 40 | Use ==. | Go |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if (data = 25) | if (data == 25) | Use ==. | R |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(99); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(99, () => console.log('listening')); | Add callback. | Node.js |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
<note name='result'/> | <note name="result"/> | Double quotes. | XML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
JOIN orders ON orders.id = orders.name | JOIN orders ON orders.id = orders.name | Correct. | SQL |
let y = 'info' | let y = "info" | Double quotes. | Swift |
function test(): void {{ return 70; }} | function test(): number {{ return 70; }} | Return type mismatch. | TypeScript |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
const user:Person = {{name:'result'}}; | const user:Person = {{name:'result', age:31}}; | Add missing property. | TypeScript |
list[96] | if (length(list) >= 96) list[96] | Check length. | R |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
var x = 47; | var x = 47; | Correct. | Dart |
SELECT age role FROM users; | SELECT age, role FROM users; | Add comma. | SQL |
val x: Int = 'output' | val x: String = 'output' | Fix type. | Kotlin |
def compute
puts 'data'
end | def compute
puts 'data'
end | Correct. | Ruby |
disp('info') | disp('info') | Correct. | MATLAB |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
def process(foo):
return foo + 1 | def process(foo):
return foo + 1 | Correct. | Python |
<ul><li>world<li>data</ul> | <ul><li>world</li><li>data</li></ul> | Close li. | HTML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
fn handle() -> i32 {{ 47 }} | fn handle() -> i32 {{ 47 }} | Correct. | Rust |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
b == '91' | b === 91 | Use strict equality. | JavaScript |
class Person {{ int val; }}
obj.val=5; | class Person {{ public int val; }}
obj.val=5; | Make field public. | Java |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
while x > 27
x -= 1 | while x > 27:
x -= 1 | Colon missing after while. | Python |
<person age=66> | <person age="66"> | Quote attribute. | XML |
echo message data | echo 'message data' | Quote to prevent splitting. | Shell |
<p>hello <b>world</p></b> | <p>hello <b>world</b></p> | Nest properly. | HTML |
[x*x for x in arr if x > 57] | [x*x for x in arr if x > 57] | Correct list comprehension. | Python |
if (temp = 99) {} | if (temp == 99) {} | Use ==. | Dart |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
function foo(result:string){{return result;}} foo(54); | function foo(result:string){{return result;}} foo('data'); | Pass correct type. | TypeScript |
#content {{ color: blue; }} | #content {{ color: blue; }} | Correct. | CSS |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
my @arr = (18,79,56); | my @arr = (18,79,56); | Correct. | Perl |
INSERT INTO products VALUES ('test',14) | INSERT INTO products (id, email) VALUES ('test',14); | Specify columns. | SQL |
if [ $z = 43 ]; then | if [ "$z" = 43 ]; then | Quote variable. | Shell |
val x = 'output' | val x = "output" | Double quotes. | Kotlin |
val bar = 34; bar = 87 | var bar = 34; bar = 87 | Use var for reassignment. | Scala |
for (b in data) | for (b of data) | for...in iterates keys. | JavaScript |
void main() {{ print('value') }} | void main() {{ print('value'); }} | Add semicolon. | Dart |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if ($val = 90) | if ($val == 90) | Use ==. | Perl |
function baz() {{
return
{{key:'world'}}
}} | function baz() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
UPDATE products SET name='message' WHERE role=88 | UPDATE products SET name='message' WHERE role=88; | Add semicolon. | SQL |
print('output') | print('output') | Correct. | R |
object Person {{ def main(args: Array[String]) = println("output") }} | object Person {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
arr(36) | if length(arr) >= 36, arr(36), end | Check length. | MATLAB |
items.forEach(function(result) {{ console.log(result); }}) | items.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.