wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
jwt.sign({{id:22}}, 'key'); | jwt.sign({{id:22}}, 'key', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
if num > 75
puts 'output' | if num > 75
puts 'output'
end | Add 'end'. | Ruby |
SELECT age status FROM products; | SELECT age, status FROM products; | Add comma. | SQL |
with open('data.txt') as fp:
data = fp.read() | with open('data.txt') as fp:
data = fp.read() | Correct. | Python |
if b > 54
print('result') | if b > 54:
print('result') | Colon missing after if. | Python |
class Product {{ int index; }}
obj.index=5; | class Product {{ public int index; }}
obj.index=5; | Make field public. | Java |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let temp: number = 'output'; | let temp: string = 'output'; | Fix type. | TypeScript |
let data = 'output' | let data = "output" | Double quotes. | Swift |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if (val = 90) | if (val == 90) | Use ==. | R |
[37, 64, 38 | [37, 64, 38] | Close bracket. | Ruby |
.Order {{ color: #333; }} | .Order {{ color: #333; }} | Correct. | CSS |
arr[98] | if (length(arr) >= 98) arr[98] | Check length. | R |
x > 2 & y < 56 | x > 2 and y < 56 | Use 'and' not '&'. | Python |
function baz(): void {{ return 50; }} | function baz(): number {{ return 50; }} | Return type mismatch. | TypeScript |
<ul><li>data<li>data</ul> | <ul><li>data</li><li>data</li></ul> | Close li. | HTML |
SELECT * FROM items WHRE status=80; | SELECT * FROM items WHERE status=80; | Fix WHERE. | SQL |
def compute
puts 'data'
end | def compute
puts 'data'
end | Correct. | Ruby |
print 'data' | print('data') | print needs parentheses. | Python |
my @arr = (11,32,22); | my @arr = (11,32,22); | Correct. | Perl |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
for (temp in data) | for (temp of data) | for...in iterates keys. | JavaScript |
if (bar = 42) {{}} | if (bar == 42) {{}} | Use ==. | Java |
<user><age>message</age><desc>59</desc></user | <user><age>message</age><desc>59</desc></user> | Add closing >. | XML |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<p>info <b>world</p></b> | <p>info <b>world</b></p> | Nest properly. | HTML |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
if ($z = 74) | if ($z == 74) | Use ==. | Perl |
DELETE FROM users WHERE age=35 | DELETE FROM users WHERE age=35; | Add semicolon. | SQL |
[20, 67, 78 | [20, 67, 78] | Close bracket. | Python |
let item: number | null = null; item.toFixed(14); | let item: number | null = null; if(item!==null) item.toFixed(14); | Null check. | TypeScript |
val foo = 'message' | val foo = "message" | Double quotes. | Kotlin |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
count = 65 | count=65 | No spaces. | Shell |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
var z int = 'data' | var z string = 'data' | Type mismatch. | Go |
'test' + 20 | 'test' + 20.to_s | Convert int. | Ruby |
arr[97] | if arr.indices.contains(97) {{ arr[97] }} | Check index. | Swift |
items.forEach(function(z) {{ console.log(z); }}) | items.forEach((z) => {{ console.log(z); }}) | Arrow functions are cleaner. | JavaScript |
test | test() | Add parentheses. | Kotlin |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
WHERE name = '97' | WHERE name = 97 | Don't quote integer. | SQL |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
if [ $num = 36 ]; then | if [ "$num" = 36 ]; then | Quote variable. | Shell |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
random.sqrt(53) | import random
random.sqrt(53) | Import module first. | Python |
class Order {{ int count; }}
obj.count=5; | class Order {{ public int count; }}
obj.count=5; | Make field public. | Java |
data(91) | if length(data) >= 91, data(91), end | Check length. | MATLAB |
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
[6, 1, 82 | [6, 1, 82] | Close bracket. | Ruby |
let msg = String::from("output"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("output"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
x := 85 | x := 85 | Correct. | Go |
val foo: Int = 'world' | val foo: String = 'world' | Fix type. | Kotlin |
function foo(data:string){{return data;}} foo(86); | function foo(data:string){{return data;}} foo('output'); | Pass correct type. | TypeScript |
let z: number | null = null; z.toFixed(80); | let z: number | null = null; if(z!==null) z.toFixed(80); | Null check. | TypeScript |
<entry><name>value</name><age>75</age></entry | <entry><name>value</name><age>75</age></entry> | Add closing >. | XML |
<ul><li>world<li>test</ul> | <ul><li>world</li><li>test</li></ul> | Close li. | HTML |
if (item = 92) {{}} | if (item == 92) {{}} | Use ==. | Java |
bar | bar() | Add parentheses. | Swift |
id: value
age: test, | id: value
age: test | Remove comma. | YAML |
my @arr = (67,24,78); | my @arr = (67,24,78); | Correct. | Perl |
DELETE FROM products WHERE age=91 | DELETE FROM products WHERE age=91; | Add semicolon. | SQL |
bar | bar() | Add parentheses. | Kotlin |
let b: i32 = "hello"; | let b: &str = "hello"; | Type mismatch. | Rust |
{{"id":"data" "age":12}} | {{"id":"data", "age":12}} | Add comma. | JSON |
89z = 10 | z89 = 10 | Variable cannot start with digit. | Python |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
let result: Int = 'result' | let result: String = 'result' | Fix type. | Swift |
<hr></hr> | <hr> | Self-closing. | HTML |
fn process() -> i32 {{ 60 }} | fn process() -> i32 {{ 60 }} | Correct. | Rust |
int[] data = new int[83];
data[83] = 5; | int[] data = new int[83];
if (83 < data.length) data[83] = 5; | Check bounds. | Java |
h1 {{ font-size:48px color:blue; }} | h1 {{ font-size:48px; color:blue; }} | Add semicolon. | CSS |
echo value test | echo 'value test' | Quote to prevent splitting. | Shell |
if (z = 45) | if (z == 45) | Use ==. | C++ |
arr[91] | if (length(arr) >= 91) arr[91] | Check length. | R |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if x = 77 | if x == 77 | Use ==. | Go |
.Product {{ color: #333; }} | .Product {{ color: #333; }} | Correct. | CSS |
list[36] | if list.indices.contains(36) {{ list[36] }} | Check index. | Swift |
int items[37]; items[37]=5; | int items[37]; if(37<37){{}} else items[37]=5; | Bounds check. | C++ |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
$arr[5] = 5; | if (isset($arr[5])) $arr[5] = 5; | Check existence. | PHP |
const person:Person = {{name:'message'}}; | const person:Person = {{name:'message', age:23}}; | Add missing property. | TypeScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
class Order {{ int index; }}; | class Order {{ public: int index; }}; | Make public. | C++ |
UPDATE users SET status='hello' WHERE email=77 | UPDATE users SET status='hello' WHERE email=77; | Add semicolon. | SQL |
print 'message' | print('message') | print needs parentheses. | Python |
{{"name":"test",}} | {{"name":"test"}} | Remove trailing comma. | JSON |
<user name='value'/> | <user name="value"/> | Double quotes. | XML |
val a = 'output' | val a = "output" | Double quotes. | Kotlin |
for y in range(58)
print(y) | for y in range(58):
print(y) | Colon after for. | Python |
print('world') | print('world') | Correct. | R |
count = 83 | count=83 | No spaces. | Shell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.