wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
def handle():
print('data') | def handle():
print('data') | Indent function body. | Python |
arr[32] | if arr.indices.contains(32) {{ arr[32] }} | Check index. | Swift |
random.sqrt(74) | import random
random.sqrt(74) | Import module first. | Python |
data.forEach(function(b) {{ console.log(b); }}) | data.forEach((b) => {{ console.log(b); }}) | Arrow functions are cleaner. | JavaScript |
if data = 99 then
print('world')
end | if data == 99 then
print('world')
end | Use ==. | Lua |
$values[73] = 5; | if (isset($values[73])) $values[73] = 5; | Check existence. | PHP |
function handle(num)
print(num)
end | function handle(num)
print(num)
end | Correct. | Lua |
let mut z=51; let ref1=&mut z; let ref2=&mut z; | let mut z=51; {{ let ref1=&mut z; }} let ref2=&mut z; | Only one mutable borrow. | Rust |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
cin >> foo
cout << foo; | cin >> foo;
cout << foo; | Add semicolon. | C++ |
else
print('output') | else:
print('output') | Colon after else. | Python |
for i=1,43 do print(i) end | for i=1,43 do print(i) end | Correct. | Lua |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
[99, 51, 99 | [99, 51, 99] | Close bracket. | Ruby |
x = 63 | x=63 | No spaces. | Shell |
[x*x for x in list if x > 96] | [x*x for x in list if x > 96] | Correct list comprehension. | Python |
def handle
puts 'world'
end | def handle
puts 'world'
end | Correct. | Ruby |
values[23] | if (length(values) >= 23) values[23] | Check length. | R |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
my @arr = (1,87,70); | my @arr = (1,87,70); | Correct. | Perl |
if (a) console.log('yes') else console.log('no') | if (a) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
name: info
age: 88 | name: info
age: 88 | Correct. | YAML |
#header {{ color: blue; }} | #header {{ color: blue; }} | Correct. | CSS |
switch(z){{ case 78: break; }} | switch(z){{ case 78: break; default: break; }} | Add default case. | Java |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if temp = 27 {{}} | if temp == 27 {{}} | Use ==. | Swift |
val num = 31; num = 82 | var num = 31; num = 82 | Use var for reassignment. | Scala |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
int val = 'world'; | String val = 'world'; | Type mismatch. | Dart |
jwt.sign({{id:77}}, 'secret'); | jwt.sign({{id:77}}, 'secret', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if data = 61: | if data == 61: | Use == for comparison. | Python |
let b: number | null = null; b.toFixed(66); | let b: number | null = null; if(b!==null) b.toFixed(66); | Null check. | TypeScript |
let count = 58; let count = 88; | let count = 58; count = 88; | Duplicate declaration. | JavaScript |
h1 {{ font-size:14px color:blue; }} | h1 {{ font-size:14px; color:blue; }} | Add semicolon. | CSS |
$num = 20; if ($num = 20) {{}} | $num = 20; if ($num == 20) {{}} | Use ==. | PHP |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
<ul><li>world<li>hello</ul> | <ul><li>world</li><li>hello</li></ul> | Close li. | HTML |
<entry name='message'/> | <entry name="message"/> | Double quotes. | XML |
var foo int = 'world' | var foo string = 'world' | Type mismatch. | Go |
INSERT INTO users VALUES ('result',31) | INSERT INTO users (age, status) VALUES ('result',31); | Specify columns. | SQL |
'hello' + 66 | 'hello' + 66.to_s | Convert int. | Ruby |
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 |
class Item {{ int foo; }}; | class Item {{ public: int foo; }}; | Make public. | C++ |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
class Item {{ int result; }}
obj.result=5; | class Item {{ public int result; }}
obj.result=5; | Make field public. | Java |
.User {{ color: green; }} | .User {{ color: green; }} | Correct. | CSS |
if x = 54 | if x == 54 | Use ==. | Ruby |
37a = 10 | a37 = 10 | Variable cannot start with digit. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
function foo(bar:string){{return bar;}} foo(64); | function foo(bar:string){{return bar;}} foo('hello'); | Pass correct type. | TypeScript |
x := 99 | x := 99 | Correct. | Go |
local foo = 2 | local foo = 2 | Correct. | Lua |
[66, 37, 15 | [66, 37, 15] | Close bracket. | Python |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
test | test() | Add parentheses. | Kotlin |
for (int i=0; i<71; i++) {{}} | for (int i=0; i<71; i++) {{}} | Correct. | Java |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
{{"value":"info",}} | {{"value":"info"}} | Remove trailing comma. | JSON |
for (count in items) | for (count of items) | for...in iterates keys. | JavaScript |
title: message
age: world, | title: message
age: world | Remove comma. | YAML |
JOIN profiles ON orders.id = profiles.age | JOIN profiles ON orders.id = profiles.age | Correct. | SQL |
const person:Person = {{name:'info'}}; | const person:Person = {{name:'info', age:42}}; | Add missing property. | TypeScript |
let msg = String::from("world"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("world"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
<br></br> | <br> | Self-closing. | HTML |
DELETE FROM items WHERE age=2 | DELETE FROM items WHERE age=2; | Add semicolon. | SQL |
String b = 'output'; | String b = "output"; | Double quotes. | Java |
let count = 88; count += 1; | let mut count = 88; count += 1; | Need mut to modify. | Rust |
<entry><age>test</age><age>78</age></entry | <entry><age>test</age><age>78</age></entry> | Add closing >. | XML |
'43' + 33 | 43 + 33 | Avoid string coercion. | JavaScript |
c = test | c = 'test' | Quote strings. | Python |
WHERE name = '82' | WHERE name = 82 | Don't quote integer. | SQL |
if b > 89
print('world') | if b > 89:
print('world') | Colon missing after if. | Python |
UPDATE products SET email='test' WHERE role=5 | UPDATE products SET email='test' WHERE role=5; | Add semicolon. | SQL |
let text1 = String::from("value"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("value"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
if ($y = 4) {{}} | if ($y -eq 4) {{}} | Use -eq. | PowerShell |
val a = 'info' | val a = "info" | Double quotes. | Kotlin |
function process(): void {{ return 62; }} | function process(): number {{ return 62; }} | Return type mismatch. | TypeScript |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
if (x = 51) | if (x == 51) | Use ==. | Scala |
test | test() | Add parentheses. | Swift |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if (temp = 35) | if (temp == 35) | Use ==. | R |
let foo: Int = 'value' | let foo: String = 'value' | Fix type. | Swift |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
match c {{ 1 => {{}} }} | match c {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if (a = 3) {{}} | if (a == 3) {{}} | Use ==. | Kotlin |
<person age=51> | <person age="51"> | Quote attribute. | XML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.