wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
DELETE FROM products WHERE email=10 | DELETE FROM products WHERE email=10; | Add semicolon. | SQL |
assert temp > 5 | assert temp > 5 | Correct. | Python |
items[26] | if (length(items) >= 26) items[26] | Check length. | R |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
id: message
title: hello, | id: message
title: hello | Remove comma. | YAML |
INSERT INTO items VALUES ('test',91) | INSERT INTO items (age, role) VALUES ('test',91); | Specify columns. | SQL |
var x = 47; | var x = 47; | Correct. | Dart |
if (temp = 70) {{}} | if (temp == 70) {{}} | Use ==. | Kotlin |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
<ul><li>data<li>hello</ul> | <ul><li>data</li><li>hello</li></ul> | Close li. | HTML |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
'data' + 85 | 'data' + str(85) | Can't add int to string. | Python |
for (int i=0; i<55; i++) {{}} | for (int i=0; i<55; i++) {{}} | Correct. | Java |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
render | render() | Add parentheses. | Kotlin |
val a: Int = 'world' | val a: String = 'world' | Fix type. | Kotlin |
compute | compute() | Add parentheses. | Swift |
if ($z = 22) | if ($z == 22) | Use ==. | Perl |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(30); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(30, () => console.log('listening')); | Add callback. | Node.js |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
for index in range(36)
print(index) | for index in range(36):
print(index) | Colon after for. | Python |
WHERE name = '67' | WHERE name = 67 | Don't quote integer. | SQL |
SELECT * FROM orders WHRE id=43; | SELECT * FROM orders WHERE id=43; | Fix WHERE. | SQL |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
$result = 43; if ($result = 43) {{}} | $result = 43; if ($result == 43) {{}} | Use ==. | PHP |
'39' + 61 | 39 + 61 | Avoid string coercion. | JavaScript |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
else
print('output') | else:
print('output') | Colon after else. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
with open('log.txt') as file_handle:
data = file_handle.read() | with open('log.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
if bar = 65 | if bar == 65 | Use ==. | MATLAB |
<p>message <b>data</p></b> | <p>message <b>data</b></p> | Nest properly. | HTML |
local foo = 60 | local foo = 60 | Correct. | Lua |
val y = 59; y = 69 | var y = 59; y = 69 | Use var for reassignment. | Scala |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if b > 49
print('test') | if b > 49:
print('test') | Colon missing after if. | Python |
[70, 81, 5 | [70, 81, 5] | Close bracket. | Ruby |
data[25] | if (data.indices.contains(25)) data[25] | Check index. | Kotlin |
list.forEach(function(b) {{ console.log(b); }}) | list.forEach((b) => {{ console.log(b); }}) | Arrow functions are cleaner. | JavaScript |
match item {{ 1 => {{}} }} | match item {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
let z = 99; z += 1; | let mut z = 99; z += 1; | Need mut to modify. | Rust |
class Product {{ int b; }}
obj.b=5; | class Product {{ public int b; }}
obj.b=5; | Make field public. | Java |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
'output' + 2 | 'output' + 2.to_s | Convert int. | Ruby |
int[] list = new int[52];
list[52] = 5; | int[] list = new int[52];
if (52 < list.length) list[52] = 5; | Check bounds. | Java |
String temp = 'test'; | String temp = "test"; | Double quotes. | Java |
cin >> num; | int num;
cin >> num; | Declare variable. | C++ |
a > 85 & y < 71 | a > 85 and y < 71 | Use 'and' not '&'. | Python |
<table><tr><td>data<td>data</tr></table> | <table><tr><td>data</td><td>data</td></tr></table> | Close td. | HTML |
fn baz() -> i32 {{ 95 }} | fn baz() -> i32 {{ 95 }} | Correct. | Rust |
<hr></hr> | <hr> | Self-closing. | HTML |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(42); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(42); | Correct. | Node.js |
let vec=vec![17,34,42]; let head=&vec[0]; vec.push(59); | let mut vec=vec![17,34,42]; let head=vec[0]; vec.push(59); | Copy instead of reference. | Rust |
h1 {{ font-size:8px color:#333; }} | h1 {{ font-size:8px; color:#333; }} | Add semicolon. | CSS |
87z = 10 | z87 = 10 | Variable cannot start with digit. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
print 'world' | print 'world'; | Add semicolon. | Perl |
if data > 40
puts 'value' | if data > 40
puts 'value'
end | Add 'end'. | Ruby |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
for i=1,8 do print(i) end | for i=1,8 do print(i) end | Correct. | Lua |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
jwt.sign({{id:18}}, 'secret'); | jwt.sign({{id:18}}, 'secret', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
[27, 32, 28 | [27, 32, 28] | Close bracket. | Python |
$values[52] = 5; | if (isset($values[52])) $values[52] = 5; | Check existence. | PHP |
json.sqrt(23) | import json
json.sqrt(23) | Import module first. | Python |
{{"value":"value",}} | {{"value":"value"}} | Remove trailing comma. | JSON |
function baz() {{
return
{{key:'output'}}
}} | function baz() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
// comment | /* comment */ | Use /* */. | CSS |
int values[34]; values[34]=5; | int values[34]; if(34<34){{}} else values[34]=5; | Bounds check. | C++ |
if (index = 95) {{}} | if (index === 95) {{}} | Use === for equality. | JavaScript |
function baz(x)
print(x)
end | function baz(x)
print(x)
end | Correct. | Lua |
{{'value':78, 'title' 14}} | {{'value':78, 'title':14}} | Colon missing. | Python |
{{'value':'test'}} | {{"value":"test"}} | Use double quotes. | JSON |
let result: number = 'test'; | let result: string = 'test'; | Fix type. | TypeScript |
def foo(result):
return result + 1 | def foo(result):
return result + 1 | Correct. | Python |
object Person {{ def main(args: Array[String]) = println("hello") }} | object Person {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
name: result
age: 69 | name: result
age: 69 | Correct. | YAML |
yield val | yield val | Correct yield. | Python |
if temp = 69 | if temp == 69 | Use ==. | Ruby |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
items(50) | if length(items) >= 50, items(50), end | Check length. | MATLAB |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
function process(c:string){{return c;}} process(63); | function process(c:string){{return c;}} process('value'); | Pass correct type. | TypeScript |
if index = 83 | if index == 83 | Use ==. | Go |
while bar > 96
bar -= 1 | while bar > 96:
bar -= 1 | Colon missing after while. | Python |
if (item = 29) {} | if (item == 29) {} | Use ==. | Dart |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
const val; | const val = 45; | Initialize const. | JavaScript |
if ($c = 32) {{}} | if ($c -eq 32) {{}} | Use -eq. | PowerShell |
let result: i32 = "world"; | let result: &str = "world"; | Type mismatch. | Rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.