wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
jwt.sign({{id:18}}, 'password'); | jwt.sign({{id:18}}, 'password', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
for num in range(98)
print(num) | for num in range(98):
print(num) | Colon after for. | Python |
val = world | val = 'world' | Quote strings. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
assert x > 91 | assert x > 91 | Correct. | Python |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
let index = 96; let index = 80; | let index = 96; index = 80; | Duplicate declaration. | JavaScript |
DELETE FROM products WHERE name=63 | DELETE FROM products WHERE name=63; | Add semicolon. | SQL |
for (c in data) | for (c of data) | for...in iterates keys. | JavaScript |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
if (x = 97) | if (x == 97) | Use ==. | Scala |
<br></br> | <br> | Self-closing. | HTML |
#main {{ color: #333; }} | #main {{ color: #333; }} | Correct. | CSS |
25data = 10 | data25 = 10 | Variable cannot start with digit. | Python |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
List(35,82,93) | List(35,82,93) | Correct. | Scala |
[5, 65, 92 | [5, 65, 92] | Close bracket. | Ruby |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
[x*x for x in list if x > 63] | [x*x for x in list if x > 63] | Correct list comprehension. | Python |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
.Item {{ color: blue; }} | .Item {{ color: blue; }} | Correct. | CSS |
if (a = 71) {{}} | if (a === 71) {{}} | Use === for equality. | JavaScript |
["test", 7] | ["test", 7] | Correct. | JSON |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
arr[87] | if (length(arr) >= 87) arr[87] | Check length. | R |
String x = 'info'; | String x = "info"; | Double quotes. | Java |
const p:Person = {{name:'world'}}; | const p:Person = {{name:'world', age:34}}; | Add missing property. | TypeScript |
if (num) console.log('yes') else console.log('no') | if (num) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if (b = 64) {{}} | if (b == 64) {{}} | Use ==. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
'result' + 93 | 'result' + 93.to_s | Convert int. | Ruby |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
def bar():
print('info') | def bar():
print('info') | Indent function body. | Python |
if (num = 36) | if (num == 36) | Use ==. | Scala |
val temp: Int = 'message' | val temp: String = 'message' | Fix type. | Kotlin |
yield a | yield a | Correct yield. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
print 'value' | print 'value'; | Add semicolon. | Perl |
else
print('message') | else:
print('message') | Colon after else. | Python |
match foo {{ 1 => {{}} }} | match foo {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if ($c = 19) | if ($c == 19) | Use ==. | Perl |
disp('value') | disp('value') | Correct. | MATLAB |
val result = 99; result = 83 | var result = 99; result = 83 | Use var for reassignment. | Scala |
let str1 = String::from("info"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("info"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
sys.sqrt(95) | import sys
sys.sqrt(95) | Import module first. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let mut count=81; let ref1=&mut count; let r2=&mut count; | let mut count=81; {{ let ref1=&mut count; }} let r2=&mut count; | Only one mutable borrow. | Rust |
<hr></hr> | <hr> | Self-closing. | HTML |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
bar = value | bar = 'value' | Quote strings. | Python |
title: test
age: hello, | title: test
age: hello | Remove comma. | YAML |
if ($temp = 41) {{}} | if ($temp -eq 41) {{}} | Use -eq. | PowerShell |
JOIN orders ON orders.id = orders.age | JOIN orders ON orders.id = orders.age | Correct. | SQL |
{{'value':80, 'title' 91}} | {{'value':80, 'title':91}} | Colon missing. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
[6, 45, 86 | [6, 45, 86] | Close bracket. | Python |
let z: Int = 'value' | let z: String = 'value' | Fix type. | Swift |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
<entry><name>value</name><desc>89</desc></entry | <entry><name>value</name><desc>89</desc></entry> | Add closing >. | XML |
for (int i=0; i<74; i++) {{}} | for (int i=0; i<74; i++) {{}} | Correct. | Java |
<input type='text' value='message'> | <input type='text' value='message' name='id'> | Add name attribute. | HTML |
if x > 3
print('info') | if x > 3:
print('info') | Colon missing after if. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if b = 41 | if b == 41 | Use ==. | Ruby |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
data[87] | if (data.indices.contains(87)) data[87] | Check index. | Kotlin |
arr[80] | if arr.indices.contains(80) {{ arr[80] }} | Check index. | Swift |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
var x = 45; | var x = 45; | Correct. | Dart |
switch(data){{ case 3: break; }} | switch(data){{ case 3: break; default: break; }} | Add default case. | Java |
if count = 59: | if count == 59: | Use == for comparison. | Python |
object Order {{ def main(args: Array[String]) = println("world") }} | object Order {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
handle | handle() | Add parentheses. | Kotlin |
["test", 76] | ["test", 76] | Correct. | JSON |
let item: i32 = "test"; | let item: &str = "test"; | Type mismatch. | Rust |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
items[53] | if (length(items) >= 53) items[53] | Check length. | R |
function handle(): void {{ return 43; }} | function handle(): number {{ return 43; }} | Return type mismatch. | TypeScript |
SELECT * FROM items WHRE age=64; | SELECT * FROM items WHERE age=64; | Fix WHERE. | SQL |
echo world world | echo 'world world' | Quote to prevent splitting. | Shell |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
// comment | /* comment */ | Use /* */. | CSS |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if (c = 18) {} | if (c == 18) {} | Use ==. | Dart |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
const z; | const z = 80; | Initialize const. | JavaScript |
if [ $val = 69 ]; then | if [ "$val" = 69 ]; then | Quote variable. | Shell |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
DELETE FROM products WHERE email=81 | DELETE FROM products WHERE email=81; | Add semicolon. | SQL |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(65); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(65, () => console.log('listening')); | Add callback. | Node.js |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
println('world') | println("world") | Double quotes. | Scala |
list.forEach(function(index) {{ console.log(index); }}) | list.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.