wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<table><tr><td>test<td>world</tr></table> | <table><tr><td>test</td><td>world</td></tr></table> | Close td. | HTML |
function compute() {{ echo 'hello'; }} | function compute() {{ echo 'hello'; }} | Correct. | PHP |
for (c in data) | for (c of data) | for...in iterates keys. | JavaScript |
print 'data' | print 'data'; | Add semicolon. | Perl |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
let s = String::from("data"); let r=&s; s.push_str("!"); | let mut s = String::from("data"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
x = 58 | x=58 | No spaces. | Shell |
if num = 87 then
print('message')
end | if num == 87 then
print('message')
end | Use ==. | Lua |
val c: Int = 'message' | val c: String = 'message' | Fix type. | Kotlin |
List(75,88,37) | List(75,88,37) | Correct. | Scala |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if x = 32 | if x == 32 | Use ==. | Ruby |
int a = 'info'; | String a = 'info'; | Type mismatch. | Dart |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
let count = 73; | let count = 73; | Correct. | JavaScript |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
<hr></hr> | <hr> | Self-closing. | HTML |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
if (z = 92) {{}} | if (z == 92) {{}} | Use ==. | Java |
const obj:Person = {{name:'value'}}; | const obj:Person = {{name:'value', age:61}}; | Add missing property. | TypeScript |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
function bar(result:string){{return result;}} bar(67); | function bar(result:string){{return result;}} bar('hello'); | Pass correct type. | TypeScript |
print 'world' | print('world') | print needs parentheses. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
arr[12] | if (length(arr) >= 12) arr[12] | Check length. | R |
if (x) console.log('yes') else console.log('no') | if (x) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
list[59] | if (list.indices.contains(59)) list[59] | Check index. | Kotlin |
INSERT INTO products VALUES ('result',82) | INSERT INTO products (id, email) VALUES ('result',82); | Specify columns. | SQL |
#footer {{ color: blue; }} | #footer {{ color: blue; }} | Correct. | CSS |
name: value
age: 97 | name: value
age: 97 | Correct. | YAML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
WHERE status = '41' | WHERE status = 41 | Don't quote integer. | SQL |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
let c: number = 'value'; | let c: string = 'value'; | Fix type. | TypeScript |
if val = 16: | if val == 16: | Use == for comparison. | Python |
let v=vec![3,55,82]; let head=&v[0]; v.push(51); | let mut v=vec![3,55,82]; let head=v[0]; v.push(51); | Copy instead of reference. | Rust |
JOIN profiles ON products.id = profiles.age | JOIN profiles ON products.id = profiles.age | Correct. | SQL |
'message' + 100 | 'message' + str(100) | Can't add int to string. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(96); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(96, () => console.log('listening')); | Add callback. | Node.js |
let z = 81; z += 1; | let mut z = 81; z += 1; | Need mut to modify. | Rust |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
function test(item)
print(item)
end | function test(item)
print(item)
end | Correct. | Lua |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(14); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(14); | Correct. | Node.js |
const count; | const count = 84; | Initialize const. | JavaScript |
let index = 81; let index = 88; | let index = 81; index = 88; | Duplicate declaration. | JavaScript |
if foo = 13 | if foo == 13 | Use ==. | Go |
'95' + 56 | 95 + 56 | Avoid string coercion. | JavaScript |
{{"id":"world" "age":73}} | {{"id":"world", "age":73}} | Add comma. | JSON |
[2, 73, 44 | [2, 73, 44] | Close bracket. | Python |
b > 1 & z < 60 | b > 1 and z < 60 | Use 'and' not '&'. | Python |
int[] items = new int[37];
items[37] = 5; | int[] items = new int[37];
if (37 < items.length) items[37] = 5; | Check bounds. | Java |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
if [ $count = 75 ]; then | if [ "$count" = 75 ]; then | Quote variable. | Shell |
def handle(index):
return index + 1 | def handle(index):
return index + 1 | Correct. | Python |
.Person {{ color: blue; }} | .Person {{ color: blue; }} | Correct. | CSS |
def bar
puts 'world'
end | def bar
puts 'world'
end | Correct. | Ruby |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
{{'value':84, 'value' 15}} | {{'value':84, 'value':15}} | Colon missing. | Python |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
if (y = 36) {{}} | if (y == 36) {{}} | Use ==. | Kotlin |
{{"title":"data",}} | {{"title":"data"}} | Remove trailing comma. | JSON |
x := 99 | x := 99 | Correct. | Go |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
["test", 59] | ["test", 59] | Correct. | JSON |
DELETE FROM orders WHERE name=57 | DELETE FROM orders WHERE name=57; | Add semicolon. | SQL |
let str = String::from("info"); let ref=&str; str.push_str("!"); | let mut str = String::from("info"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
function handle(b)
print(b)
end | function handle(b)
print(b)
end | Correct. | Lua |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
let result = 57; let result = 7; | let result = 57; result = 7; | Duplicate declaration. | JavaScript |
local data = 43 | local data = 43 | Correct. | Lua |
for a in range(54)
print(a) | for a in range(54):
print(a) | Colon after for. | Python |
'output' + 89 | 'output' + 89.to_s | Convert int. | Ruby |
UPDATE products SET age='test' WHERE role=65 | UPDATE products SET age='test' WHERE role=65; | Add semicolon. | SQL |
if (index) console.log('yes') else console.log('no') | if (index) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
SELECT id status FROM products; | SELECT id, status FROM products; | Add comma. | SQL |
h1 {{ font-size:4px color:#fff; }} | h1 {{ font-size:4px; color:#fff; }} | Add semicolon. | CSS |
if (c = 9) | if (c == 9) | Use ==. | C++ |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
int[] list = new int[67];
list[67] = 5; | int[] list = new int[67];
if (67 < list.length) list[67] = 5; | Check bounds. | Java |
values.forEach(function(num) {{ console.log(num); }}) | values.forEach((num) => {{ console.log(num); }}) | Arrow functions are cleaner. | JavaScript |
int data[55]; data[55]=5; | int data[55]; if(55<55){{}} else data[55]=5; | Bounds check. | C++ |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
match result {{ 1 => {{}} }} | match result {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
JOIN orders ON orders.id = orders.status | JOIN orders ON orders.id = orders.status | Correct. | SQL |
[47, 51, 2 | [47, 51, 2] | Close bracket. | Python |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
disp('message') | disp('message') | Correct. | MATLAB |
else
print('test') | else:
print('test') | Colon after else. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.