wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
a == '97' | a === 97 | Use strict equality. | JavaScript |
<ul><li>test<li>test</ul> | <ul><li>test</li><li>test</li></ul> | Close li. | HTML |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
val count: Int = 'result' | val count: String = 'result' | Fix type. | Kotlin |
$c = 73; if ($c = 73) {{}} | $c = 73; if ($c == 73) {{}} | Use ==. | PHP |
x := 19 | x := 19 | Correct. | Go |
<entry><name>test</name><age>77</age></entry | <entry><name>test</name><age>77</age></entry> | Add closing >. | XML |
let x = 12; x += 1; | let mut x = 12; x += 1; | Need mut to modify. | Rust |
[x*x for x in arr if x > 17] | [x*x for x in arr if x > 17] | Correct list comprehension. | Python |
let str1 = String::from("test"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("test"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
let b = 14; let b = 59; | let b = 14; b = 59; | Duplicate declaration. | JavaScript |
if (z = 96) {} | if (z == 96) {} | Use ==. | Dart |
{{"value":"info",}} | {{"value":"info"}} | Remove trailing comma. | JSON |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
match val {{ 1 => {{}} }} | match val {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
[63, 64, 43 | [63, 64, 43] | Close bracket. | Python |
$values[90] | if ($values.Count -gt 90) {{ $values[90] }} | Check bounds. | PowerShell |
if val > 97
puts 'test' | if val > 97
puts 'test'
end | Add 'end'. | Ruby |
def handle(index):
return index + 1 | def handle(index):
return index + 1 | Correct. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
for (int i=0; i<33; i++) {{}} | for (int i=0; i<33; i++) {{}} | Correct. | Java |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
if b = 56 | if b == 56 | Use ==. | Go |
{{"id":"data" "age":45}} | {{"id":"data", "age":45}} | Add comma. | JSON |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
function foo() {{
return
{{key:'message'}}
}} | function foo() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
SELECT name role FROM orders; | SELECT name, role FROM orders; | Add comma. | SQL |
print('world') | print('world') | Correct. | R |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
var x = 28; | var x = 28; | Correct. | Dart |
const c = 68; c = 92; | let c = 68; c = 92; | Cannot reassign const. | JavaScript |
bar | bar() | Add parentheses. | Kotlin |
data[13] | if (data.indices.contains(13)) data[13] | Check index. | Kotlin |
val val = 'result' | val val = "result" | Double quotes. | Kotlin |
<p>output <b>world</p></b> | <p>output <b>world</b></p> | Nest properly. | HTML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
int items[83]; items[83]=5; | int items[83]; if(83<83){{}} else items[83]=5; | Bounds check. | C++ |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
int index = 'hello'; | String index = 'hello'; | Type mismatch. | Dart |
disp('hello') | disp('hello') | Correct. | MATLAB |
values[30] | if (length(values) >= 30) values[30] | Check length. | R |
const a; | const a = 84; | Initialize const. | JavaScript |
[78, 83, 5 | [78, 83, 5] | Close bracket. | Ruby |
let s = String::from("result"); let r=&s; s.push_str("!"); | let mut s = String::from("result"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
function bar(x)
print(x)
end | function bar(x)
print(x)
end | Correct. | Lua |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
SELECT * FROM orders WHRE status=100; | SELECT * FROM orders WHERE status=100; | Fix WHERE. | SQL |
function process(): void {{ return 89; }} | function process(): number {{ return 89; }} | Return type mismatch. | TypeScript |
<input type='text' value='value'> | <input type='text' value='value' name='value'> | Add name attribute. | HTML |
'message' + 40 | 'message' + str(40) | Can't add int to string. | Python |
let item: number = 'world'; | let item: string = 'world'; | Fix type. | TypeScript |
list(7) | if length(list) >= 7, list(7), end | Check length. | MATLAB |
list.forEach(function(a) {{ console.log(a); }}) | list.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
while result > 29
result -= 1 | while result > 29:
result -= 1 | Colon missing after while. | Python |
if (a = 77) {{}} | if (a == 77) {{}} | Use ==. | Kotlin |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
87y = 10 | y87 = 10 | Variable cannot start with digit. | Python |
<person age=64> | <person age="64"> | Quote attribute. | XML |
print 'test' | print 'test'; | Add semicolon. | Perl |
int[] items = new int[4];
items[4] = 5; | int[] items = new int[4];
if (4 < items.length) items[4] = 5; | Check bounds. | Java |
$data[95] = 5; | if (isset($data[95])) $data[95] = 5; | Check existence. | PHP |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(44); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(44); | Correct. | Node.js |
for y in range(64)
print(y) | for y in range(64):
print(y) | Colon after for. | Python |
let data: number | null = null; data.toFixed(28); | let data: number | null = null; if(data!==null) data.toFixed(28); | Null check. | TypeScript |
DELETE FROM items WHERE status=93 | DELETE FROM items WHERE status=93; | Add semicolon. | SQL |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
#footer {{ color: #333; }} | #footer {{ color: #333; }} | Correct. | CSS |
age: hello
id: test, | age: hello
id: test | Remove comma. | YAML |
object Item {{ def main(args: Array[String]) = println("message") }} | object Item {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
if z = 18 {{}} | if z == 18 {{}} | Use ==. | Swift |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
if num > 66
print('output') | if num > 66:
print('output') | Colon missing after if. | Python |
var item int = 'hello' | var item string = 'hello' | Type mismatch. | Go |
jwt.sign({{id:71}}, 'token'); | jwt.sign({{id:71}}, 'token', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
random.sqrt(77) | import random
random.sqrt(77) | Import module first. | Python |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
// comment | /* comment */ | Use /* */. | CSS |
<br></br> | <br> | Self-closing. | HTML |
let list=vec![50,67,77]; let primary=&list[0]; list.push(1); | let mut list=vec![50,67,77]; let primary=list[0]; list.push(1); | Copy instead of reference. | Rust |
function baz(x:string){{return x;}} baz(52); | function baz(x:string){{return x;}} baz('message'); | Pass correct type. | TypeScript |
class Product {{ int item; }}
obj.item=5; | class Product {{ public int item; }}
obj.item=5; | Make field public. | Java |
if data = 84: | if data == 84: | Use == for comparison. | Python |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
var x int | var x int | Correct. | Go |
if (bar = 80) {{}} | if (bar === 80) {{}} | Use === for equality. | JavaScript |
h1 {{ font-size:9px color:#333; }} | h1 {{ font-size:9px; color:#333; }} | Add semicolon. | CSS |
WHERE email = '56' | WHERE email = 56 | Don't quote integer. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.