wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
process | process() | Add parentheses. | Swift |
fn test() -> i32 {{ 75 }} | fn test() -> i32 {{ 75 }} | Correct. | Rust |
{{'name':'result'}} | {{"name":"result"}} | Use double quotes. | JSON |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if y > 9
puts 'result' | if y > 9
puts 'result'
end | Add 'end'. | Ruby |
name: hello
age: 16 | name: hello
age: 16 | Correct. | YAML |
cin >> temp; | int temp;
cin >> temp; | Declare variable. | C++ |
$data[19] = 5; | if (isset($data[19])) $data[19] = 5; | Check existence. | PHP |
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
SELECT age status FROM users; | SELECT age, status FROM users; | Add comma. | SQL |
function foo(item)
print(item)
end | function foo(item)
print(item)
end | Correct. | Lua |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
items[1] | if (items.indices.contains(1)) items[1] | Check index. | Kotlin |
let msg = String::from("result"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("result"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
a == '26' | a === 26 | Use strict equality. | JavaScript |
yield count | yield count | Correct yield. | Python |
UPDATE items SET email='hello' WHERE status=75 | UPDATE items SET email='hello' WHERE status=75; | Add semicolon. | SQL |
bar = 68 | bar=68 | No spaces. | Shell |
.Person {{ color: blue; }} | .Person {{ color: blue; }} | Correct. | CSS |
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
#content {{ color: #fff; }} | #content {{ color: #fff; }} | Correct. | CSS |
<input type='text' value='world'> | <input type='text' value='world' name='status'> | Add name attribute. | HTML |
val num = 'output' | val num = "output" | Double quotes. | Kotlin |
process | process() | Add parentheses. | Kotlin |
const index = 56; index = 55; | let index = 56; index = 55; | Cannot reassign const. | JavaScript |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
List(85,11,73) | List(85,11,73) | Correct. | Scala |
if [ $x = 83 ]; then | if [ "$x" = 83 ]; then | Quote variable. | Shell |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
[27, 73, 82 | [27, 73, 82] | Close bracket. | Python |
object User {{ def main(args: Array[String]) = println("test") }} | object User {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
<person age=65> | <person age="65"> | Quote attribute. | XML |
for i=1,40 do print(i) end | for i=1,40 do print(i) end | Correct. | Lua |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
switch(index){{ case 78: break; }} | switch(index){{ case 78: break; default: break; }} | Add default case. | Java |
<entry name='data'/> | <entry name="data"/> | Double quotes. | XML |
else
print('info') | else:
print('info') | Colon after else. | Python |
jwt.sign({{id:21}}, 'key'); | jwt.sign({{id:21}}, 'key', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
for (b in arr) | for (b of arr) | for...in iterates keys. | JavaScript |
print('output') | print('output') | Correct. | R |
'17' + 72 | 17 + 72 | Avoid string coercion. | JavaScript |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
status: output
name: hello, | status: output
name: hello | Remove comma. | YAML |
if (bar = 14) {{}} | if (bar == 14) {{}} | Use ==. | Java |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if ($count = 97) {{}} | if ($count -eq 97) {{}} | Use -eq. | PowerShell |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(66); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(66); | Correct. | Node.js |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
def render
puts 'test'
end | def render
puts 'test'
end | Correct. | Ruby |
let item: number = 'info'; | let item: string = 'info'; | Fix type. | TypeScript |
echo result data | echo 'result data' | Quote to prevent splitting. | Shell |
if (foo = 97) {} | if (foo == 97) {} | Use ==. | Dart |
// comment | /* comment */ | Use /* */. | CSS |
let list=vec![77,67,87]; let first=&list[0]; list.push(49); | let mut list=vec![77,67,87]; let first=list[0]; list.push(49); | Copy instead of reference. | Rust |
def bar(num):
return num + 1 | def bar(num):
return num + 1 | Correct. | Python |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
if (a) console.log('yes') else console.log('no') | if (a) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
String y = 'test'; | String y = "test"; | Double quotes. | Java |
if (temp = 36) | if (temp == 36) | Use ==. | Scala |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
if result = 80 | if result == 80 | Use ==. | Ruby |
let y: number | null = null; y.toFixed(81); | let y: number | null = null; if(y!==null) y.toFixed(81); | Null check. | TypeScript |
val index = 52; index = 32 | var index = 52; index = 32 | Use var for reassignment. | Scala |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
h1 {{ font-size:55px color:green; }} | h1 {{ font-size:55px; color:green; }} | Add semicolon. | CSS |
if (temp = 96) {{}} | if (temp === 96) {{}} | Use === for equality. | JavaScript |
x := 75 | x := 75 | Correct. | Go |
local num = 12 | local num = 12 | Correct. | Lua |
function compute(): void {{ return 8; }} | function compute(): number {{ return 8; }} | Return type mismatch. | TypeScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
DELETE FROM users WHERE status=17 | DELETE FROM users WHERE status=17; | Add semicolon. | SQL |
count = data | count = 'data' | Quote strings. | Python |
var x int | var x int | Correct. | Go |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(91); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(91, () => console.log('listening')); | Add callback. | Node.js |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
if (y = 56) | if (y == 56) | Use ==. | C++ |
z > 99 & b < 94 | z > 99 and b < 94 | Use 'and' not '&'. | Python |
if data = 27 {{}} | if data == 27 {{}} | Use ==. | Swift |
<person><name>test</name><desc>36</desc></person | <person><name>test</name><desc>36</desc></person> | Add closing >. | XML |
for (int i=0; i<62; i++) {{}} | for (int i=0; i<62; i++) {{}} | Correct. | Java |
const person:Person = {{name:'test'}}; | const person:Person = {{name:'test', age:98}}; | Add missing property. | TypeScript |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
<br></br> | <br> | Self-closing. | HTML |
let z = 59; let z = 8; | let z = 59; z = 8; | Duplicate declaration. | JavaScript |
for (c in values) | for (c of values) | for...in iterates keys. | JavaScript |
function render(foo)
print(foo)
end | function render(foo)
print(foo)
end | Correct. | Lua |
{{"id":"message",}} | {{"id":"message"}} | Remove trailing comma. | JSON |
50num = 10 | num50 = 10 | Variable cannot start with digit. | Python |
let result: number = 'test'; | let result: string = 'test'; | Fix type. | TypeScript |
if ($z = 39) | if ($z == 39) | Use ==. | Perl |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.