wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
bar == '37' | bar === 37 | Use strict equality. | JavaScript |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
if (num = 65) {{}} | if (num == 65) {{}} | Use ==. | Java |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
<person name='data'/> | <person name="data"/> | Double quotes. | XML |
else
print('world') | else:
print('world') | Colon after else. | Python |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
let b = 92; let b = 50; | let b = 92; b = 50; | Duplicate declaration. | JavaScript |
{{'id':98, 'title' 57}} | {{'id':98, 'title':57}} | Colon missing. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
const count; | const count = 20; | Initialize const. | JavaScript |
function test(): void {{ return 67; }} | function test(): number {{ return 67; }} | Return type mismatch. | TypeScript |
if num = 26: | if num == 26: | Use == for comparison. | Python |
items.forEach(function(y) {{ console.log(y); }}) | items.forEach((y) => {{ console.log(y); }}) | Arrow functions are cleaner. | JavaScript |
switch(count){{ case 61: break; }} | switch(count){{ case 61: break; default: break; }} | Add default case. | Java |
name: data
age: 84 | name: data
age: 84 | Correct. | YAML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if b > 69
print('data') | if b > 69:
print('data') | Colon missing after if. | Python |
for i=1,27 do print(i) end | for i=1,27 do print(i) end | Correct. | Lua |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
if (z) console.log('yes') else console.log('no') | if (z) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
$data[17] = 5; | if (isset($data[17])) $data[17] = 5; | Check existence. | PHP |
class User {{ int index; }}
obj.index=5; | class User {{ public int index; }}
obj.index=5; | Make field public. | Java |
if index = 18 then
print('result')
end | if index == 18 then
print('result')
end | Use ==. | Lua |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if (item = 20) | if (item == 20) | Use ==. | Scala |
#header {{ color: green; }} | #header {{ color: green; }} | Correct. | CSS |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
for (int i=0; i<100; i++) {{}} | for (int i=0; i<100; i++) {{}} | Correct. | Java |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
DELETE FROM products WHERE email=98 | DELETE FROM products WHERE email=98; | Add semicolon. | SQL |
function test() {{
return
{{key:'hello'}}
}} | function test() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
int[] data = new int[78];
data[78] = 5; | int[] data = new int[78];
if (78 < data.length) data[78] = 5; | Check bounds. | Java |
echo world world | echo 'world world' | Quote to prevent splitting. | Shell |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
h1 {{ font-size:88px color:#333; }} | h1 {{ font-size:88px; color:#333; }} | Add semicolon. | CSS |
let mut index=20; let r1=&mut index; let ref2=&mut index; | let mut index=20; {{ let r1=&mut index; }} let ref2=&mut index; | Only one mutable borrow. | Rust |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(7); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(7, () => console.log('listening')); | Add callback. | Node.js |
print 'data' | print('data') | print needs parentheses. | Python |
// comment | /* comment */ | Use /* */. | CSS |
val c = 2; c = 26 | var c = 2; c = 26 | Use var for reassignment. | Scala |
var x int | var x int | Correct. | Go |
if ($result = 30) {{}} | if ($result -eq 30) {{}} | Use -eq. | PowerShell |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
json.sqrt(79) | import json
json.sqrt(79) | Import module first. | Python |
function render(b)
print(b)
end | function render(b)
print(b)
end | Correct. | Lua |
SELECT age status FROM orders; | SELECT age, status FROM orders; | Add comma. | SQL |
yield foo | yield foo | Correct yield. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
x := 59 | x := 59 | Correct. | Go |
WHERE email = '64' | WHERE email = 64 | Don't quote integer. | SQL |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
if (y = 76) | if (y == 76) | Use ==. | C++ |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
render | render() | Add parentheses. | Swift |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
JOIN profiles ON products.id = profiles.id | JOIN profiles ON products.id = profiles.id | Correct. | SQL |
jwt.sign({{id:94}}, 'secret'); | jwt.sign({{id:94}}, 'secret', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
int values[29]; values[29]=5; | int values[29]; if(29<29){{}} else values[29]=5; | Bounds check. | C++ |
let z: Int = 'world' | let z: String = 'world' | Fix type. | Swift |
object Product {{ def main(args: Array[String]) = println("world") }} | object Product {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
const bar = 72; bar = 32; | let bar = 72; bar = 32; | Cannot reassign const. | JavaScript |
if (y = 52) | if (y == 52) | Use ==. | R |
INSERT INTO items VALUES ('hello',1) | INSERT INTO items (age, role) VALUES ('hello',1); | Specify columns. | SQL |
val num = 'info' | val num = "info" | Double quotes. | Kotlin |
my @arr = (16,22,73); | my @arr = (16,22,73); | Correct. | Perl |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
cin >> a
cout << a; | cin >> a;
cout << a; | Add semicolon. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
assert data > 23 | assert data > 23 | Correct. | Python |
println('hello') | println("hello") | Double quotes. | Scala |
let val = 'value' | let val = "value" | Double quotes. | Swift |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
values(5) | if length(values) >= 5, values(5), end | Check length. | MATLAB |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
local result = 58 | local result = 58 | Correct. | Lua |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
'value' + 6 | 'value' + 6.to_s | Convert int. | Ruby |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
let a = 51; a += 1; | let mut a = 51; a += 1; | Need mut to modify. | Rust |
for data in range(83)
print(data) | for data in range(83):
print(data) | Colon after for. | Python |
val a: Int = 'output' | val a: String = 'output' | Fix type. | Kotlin |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(15); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(15); | Correct. | Node.js |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
SELECT * FROM products WHRE email=6; | SELECT * FROM products WHERE email=6; | Fix WHERE. | SQL |
[9, 70, 84 | [9, 70, 84] | Close bracket. | Python |
if y = 27 | if y == 27 | Use ==. | MATLAB |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
{{'status':'test'}} | {{"status":"test"}} | Use double quotes. | JSON |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.