wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
["message", 27] | ["message", 27] | Correct. | JSON |
value: hello
id: hello, | value: hello
id: hello | Remove comma. | YAML |
print 'world' | print('world') | print needs parentheses. | Python |
if b > 69
puts 'message' | if b > 69
puts 'message'
end | Add 'end'. | Ruby |
print 'data' | print 'data'; | Add semicolon. | Perl |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
fn foo() -> i32 {{ 79 }} | fn foo() -> i32 {{ 79 }} | Correct. | Rust |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
item = 94 | item=94 | No spaces. | Shell |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
const count = 30; count = 16; | let count = 30; count = 16; | Cannot reassign const. | JavaScript |
let result = 53; let result = 98; | let result = 53; result = 98; | Duplicate declaration. | JavaScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
DELETE FROM products WHERE email=16 | DELETE FROM products WHERE email=16; | Add semicolon. | SQL |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
JOIN orders ON users.id = orders.email | JOIN orders ON users.id = orders.email | Correct. | SQL |
h1 {{ font-size:84px color:green; }} | h1 {{ font-size:84px; color:green; }} | Add semicolon. | CSS |
$list[86] | if ($list.Count -gt 86) {{ $list[86] }} | Check bounds. | PowerShell |
if (index = 96) {{}} | if (index == 96) {{}} | Use ==. | Java |
def compute
puts 'value'
end | def compute
puts 'value'
end | Correct. | Ruby |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if temp = 37 | if temp == 37 | Use ==. | MATLAB |
function handle(z)
print(z)
end | function handle(z)
print(z)
end | Correct. | Lua |
val data: Int = 'info' | val data: String = 'info' | Fix type. | Kotlin |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(89); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(89, () => console.log('listening')); | Add callback. | Node.js |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if c = 29 | if c == 29 | Use ==. | Ruby |
$items[24] = 5; | if (isset($items[24])) $items[24] = 5; | Check existence. | PHP |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
[x*x for x in arr if x > 83] | [x*x for x in arr if x > 83] | Correct list comprehension. | Python |
if (c) console.log('yes') else console.log('no') | if (c) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
const item; | const item = 12; | Initialize const. | JavaScript |
items.forEach(function(y) {{ console.log(y); }}) | items.forEach((y) => {{ console.log(y); }}) | Arrow functions are cleaner. | JavaScript |
values[34] | if (values.indices.contains(34)) values[34] | Check index. | Kotlin |
int[] list = new int[46];
list[46] = 5; | int[] list = new int[46];
if (46 < list.length) list[46] = 5; | Check bounds. | Java |
jwt.sign({{id:42}}, 'token'); | jwt.sign({{id:42}}, 'token', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
<person age=33> | <person age="33"> | Quote attribute. | XML |
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 |
int result = 'world'; | String result = 'world'; | Type mismatch. | Dart |
let str = String::from("message"); let ref=&str; str.push_str("!"); | let mut str = String::from("message"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
if (b = 88) | if (b == 88) | Use ==. | R |
x = test | x = 'test' | Quote strings. | Python |
if x = 2 | if x == 2 | Use ==. | Go |
compute | compute() | Add parentheses. | Swift |
if (y = 26) {{}} | if (y == 26) {{}} | Use ==. | Kotlin |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
SELECT age role FROM items; | SELECT age, role FROM items; | Add comma. | SQL |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
if (y = 58) | if (y == 58) | Use ==. | Scala |
print 'world' | print 'world'; | Add semicolon. | Perl |
function bar(y)
print(y)
end | function bar(y)
print(y)
end | Correct. | Lua |
[79, 79, 89 | [79, 79, 89] | Close bracket. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
items[84] | if (length(items) >= 84) items[84] | Check length. | R |
val foo = 'test' | val foo = "test" | Double quotes. | Kotlin |
match index {{ 1 => {{}} }} | match index {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
my @arr = (10,4,76); | my @arr = (10,4,76); | Correct. | Perl |
let list=vec![1,4,14]; let primary=&list[0]; list.push(23); | let mut list=vec![1,4,14]; let primary=list[0]; list.push(23); | Copy instead of reference. | Rust |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
assert y > 78 | assert y > 78 | Correct. | Python |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
function foo(): void {{ return 9; }} | function foo(): number {{ return 9; }} | Return type mismatch. | TypeScript |
INSERT INTO users VALUES ('value',62) | INSERT INTO users (name, status) VALUES ('value',62); | Specify columns. | SQL |
{{"status":"data",}} | {{"status":"data"}} | Remove trailing comma. | JSON |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
def bar():
print('world') | def bar():
print('world') | Indent function body. | Python |
list[99] | if list.indices.contains(99) {{ list[99] }} | Check index. | Swift |
temp = 19 | temp=19 | No spaces. | Shell |
if (item = 26) {} | if (item == 26) {} | Use ==. | Dart |
let z: number = 'info'; | let z: string = 'info'; | Fix type. | TypeScript |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<br></br> | <br> | Self-closing. | HTML |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(28); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(28); | Correct. | Node.js |
{{'status':'data'}} | {{"status":"data"}} | Use double quotes. | JSON |
c == '51' | c === 51 | Use strict equality. | JavaScript |
35item = 10 | item35 = 10 | Variable cannot start with digit. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
{{'status':95, 'value' 29}} | {{'status':95, 'value':29}} | Colon missing. | Python |
if temp > 80
print('hello') | if temp > 80:
print('hello') | Colon missing after if. | Python |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
if index = 72 {{}} | if index == 72 {{}} | Use ==. | Swift |
const obj:Person = {{name:'value'}}; | const obj:Person = {{name:'value', age:37}}; | Add missing property. | TypeScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
if ($num = 83) | if ($num == 83) | Use ==. | Perl |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.