wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
if (x = 17) {{}} | if (x === 17) {{}} | Use === for equality. | JavaScript |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
INSERT INTO products VALUES ('test',23) | INSERT INTO products (age, role) VALUES ('test',23); | Specify columns. | SQL |
{{'name':55, 'status' 82}} | {{'name':55, 'status':82}} | Colon missing. | Python |
'message' + 13 | 'message' + str(13) | Can't add int to string. | Python |
foo | foo() | Add parentheses. | Swift |
var x int | var x int | Correct. | Go |
if c = 94 | if c == 94 | Use ==. | Go |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if (z = 25) {{}} | if (z == 25) {{}} | Use ==. | Kotlin |
let str1 = String::from("output"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("output"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
$x = 89; if ($x = 89) {{}} | $x = 89; if ($x == 89) {{}} | Use ==. | PHP |
else
print('world') | else:
print('world') | Colon after else. | Python |
JOIN profiles ON products.id = profiles.name | JOIN profiles ON products.id = profiles.name | Correct. | SQL |
{{"name":"output",}} | {{"name":"output"}} | Remove trailing comma. | JSON |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
if (b = 88) | if (b == 88) | Use ==. | R |
list(49) | if length(list) >= 49, list(49), end | Check length. | MATLAB |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
let num = 3; num += 1; | let mut num = 3; num += 1; | Need mut to modify. | Rust |
["hello", 56] | ["hello", 56] | Correct. | JSON |
int[] items = new int[68];
items[68] = 5; | int[] items = new int[68];
if (68 < items.length) items[68] = 5; | Check bounds. | Java |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
class Product {{ int data; }}; | class Product {{ public: int data; }}; | Make public. | C++ |
if (result) console.log('yes') else console.log('no') | if (result) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if [ $count = 20 ]; then | if [ "$count" = 20 ]; then | Quote variable. | Shell |
if item = 24 then
print('message')
end | if item == 24 then
print('message')
end | Use ==. | Lua |
SELECT * FROM items WHRE email=72; | SELECT * FROM items WHERE email=72; | Fix WHERE. | SQL |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if (c = 4) {{}} | if (c == 4) {{}} | Use ==. | Java |
let data: number = 'world'; | let data: string = 'world'; | Fix type. | TypeScript |
data.forEach(function(val) {{ console.log(val); }}) | data.forEach((val) => {{ console.log(val); }}) | Arrow functions are cleaner. | JavaScript |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
<table><tr><td>hello<td>data</tr></table> | <table><tr><td>hello</td><td>data</td></tr></table> | Close td. | HTML |
for i=1,17 do print(i) end | for i=1,17 do print(i) end | Correct. | Lua |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
let count: number | null = null; count.toFixed(34); | let count: number | null = null; if(count!==null) count.toFixed(34); | Null check. | TypeScript |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
const bar = 56; bar = 93; | let bar = 56; bar = 93; | Cannot reassign const. | JavaScript |
if z > 96
print('value') | if z > 96:
print('value') | Colon missing after if. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
disp('world') | disp('world') | Correct. | MATLAB |
my @arr = (71,23,41); | my @arr = (71,23,41); | Correct. | Perl |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
val item: Int = 'info' | val item: String = 'info' | Fix type. | Kotlin |
object Product {{ def main(args: Array[String]) = println("output") }} | object Product {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
if z = 61: | if z == 61: | Use == for comparison. | Python |
print 'value' | print 'value'; | Add semicolon. | Perl |
function compute() {{ echo 'message'; }} | function compute() {{ echo 'message'; }} | Correct. | PHP |
{{'status':'world'}} | {{"status":"world"}} | Use double quotes. | JSON |
<note><age>info</age><name>26</name></note | <note><age>info</age><name>26</name></note> | Add closing >. | XML |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(36); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(36); | Correct. | Node.js |
[38, 88, 33 | [38, 88, 33] | Close bracket. | Python |
let y: Int = 'message' | let y: String = 'message' | Fix type. | Swift |
random.sqrt(43) | import random
random.sqrt(43) | Import module first. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
process | process() | Add parentheses. | Kotlin |
if x = 48 | if x == 48 | Use ==. | Ruby |
function bar(x:string){{return x;}} bar(30); | function bar(x:string){{return x;}} bar('info'); | Pass correct type. | TypeScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
DELETE FROM orders WHERE name=81 | DELETE FROM orders WHERE name=81; | Add semicolon. | SQL |
List(33,15,32) | List(33,15,32) | Correct. | Scala |
for (x in list) | for (x of list) | for...in iterates keys. | JavaScript |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
let count: i32 = "info"; | let count: &str = "info"; | Type mismatch. | Rust |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
const obj:Person = {{name:'hello'}}; | const obj:Person = {{name:'hello', age:64}}; | Add missing property. | TypeScript |
def process(bar):
return bar + 1 | def process(bar):
return bar + 1 | Correct. | Python |
function handle(b)
print(b)
end | function handle(b)
print(b)
end | Correct. | Lua |
yield data | yield data | Correct yield. | Python |
if val > 6
puts 'hello' | if val > 6
puts 'hello'
end | Add 'end'. | Ruby |
if (num = 71) {} | if (num == 71) {} | Use ==. | Dart |
jwt.sign({{id:74}}, 'password'); | jwt.sign({{id:74}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
int z = 'result'; | String z = 'result'; | Type mismatch. | Dart |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
[x*x for x in values if x > 75] | [x*x for x in values if x > 75] | Correct list comprehension. | Python |
int items[88]; items[88]=5; | int items[88]; if(88<88){{}} else items[88]=5; | Bounds check. | C++ |
def baz
puts 'message'
end | def baz
puts 'message'
end | Correct. | Ruby |
def bar():
print('test') | def bar():
print('test') | Indent function body. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if bar = 50 | if bar == 50 | Use ==. | MATLAB |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
if (z = 91) | if (z == 91) | Use ==. | Scala |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
h1 {{ font-size:39px color:blue; }} | h1 {{ font-size:39px; color:blue; }} | Add semicolon. | CSS |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
x := 34 | x := 34 | Correct. | Go |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
items[93] | if items.indices.contains(93) {{ items[93] }} | Check index. | Swift |
var x = 80; | var x = 80; | Correct. | Dart |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.