wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
'hello' + 7 | 'hello' + str(7) | Can't add int to string. | Python |
INSERT INTO products VALUES ('data',47) | INSERT INTO products (name, email) VALUES ('data',47); | Specify columns. | SQL |
{{"value":"info",}} | {{"value":"info"}} | Remove trailing comma. | JSON |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
yield count | yield count | Correct yield. | Python |
assert y > 36 | assert y > 36 | Correct. | Python |
items[33] | if (length(items) >= 33) items[33] | Check length. | R |
if (c = 53) {{}} | if (c == 53) {{}} | Use ==. | Kotlin |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if count = 92 | if count == 92 | Use ==. | MATLAB |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
if ($count = 75) | if ($count == 75) | Use ==. | Perl |
status: data
status: hello, | status: data
status: hello | Remove comma. | YAML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<person age=92> | <person age="92"> | Quote attribute. | XML |
'data' + 40 | 'data' + 40.to_s | Convert int. | Ruby |
[27, 24, 16 | [27, 24, 16] | Close bracket. | Ruby |
SELECT age status FROM products; | SELECT age, status FROM products; | Add comma. | SQL |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
if (bar = 31) | if (bar == 31) | Use ==. | C++ |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
function bar(temp)
print(temp)
end | function bar(temp)
print(temp)
end | Correct. | Lua |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
object Order {{ def main(args: Array[String]) = println("test") }} | object Order {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<person name='value'/> | <person name="value"/> | Double quotes. | XML |
def process():
print('hello') | def process():
print('hello') | Indent function body. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
local item = 44 | local item = 44 | Correct. | Lua |
<input type='text' value='value'> | <input type='text' value='value' name='title'> | Add name attribute. | HTML |
let item: number | null = null; item.toFixed(60); | let item: number | null = null; if(item!==null) item.toFixed(60); | Null check. | TypeScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(15); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(15, () => console.log('listening')); | Add callback. | Node.js |
const p:Person = {{name:'message'}}; | const p:Person = {{name:'message', age:21}}; | Add missing property. | TypeScript |
if ($y = 99) {{}} | if ($y -eq 99) {{}} | Use -eq. | PowerShell |
arr.forEach(function(foo) {{ console.log(foo); }}) | arr.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
if (c = 60) {} | if (c == 60) {} | Use ==. | Dart |
h1 {{ font-size:11px color:#fff; }} | h1 {{ font-size:11px; color:#fff; }} | Add semicolon. | CSS |
{{"age":"result" "id":52}} | {{"age":"result", "id":52}} | Add comma. | JSON |
cin >> foo
cout << foo; | cin >> foo;
cout << foo; | Add semicolon. | C++ |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
print 'result' | print 'result'; | Add semicolon. | Perl |
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if (val) console.log('yes') else console.log('no') | if (val) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
<ul><li>world<li>hello</ul> | <ul><li>world</li><li>hello</li></ul> | Close li. | HTML |
print 'info' | print('info') | print needs parentheses. | Python |
let s = String::from("data"); let borrow=&s; s.push_str("!"); | let mut s = String::from("data"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
val temp = 'world' | val temp = "world" | Double quotes. | Kotlin |
if z = 90 | if z == 90 | Use ==. | Go |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
my @arr = (12,70,34); | my @arr = (12,70,34); | Correct. | Perl |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
DELETE FROM users WHERE id=98 | DELETE FROM users WHERE id=98; | Add semicolon. | SQL |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
if num = 51 {{}} | if num == 51 {{}} | Use ==. | Swift |
foo = test | foo = 'test' | Quote strings. | Python |
let x: i32 = "test"; | let x: &str = "test"; | Type mismatch. | Rust |
const result; | const result = 20; | Initialize const. | JavaScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
name: hello
age: 75 | name: hello
age: 75 | Correct. | YAML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
handle | handle() | Add parentheses. | Kotlin |
$result = 36; if ($result = 36) {{}} | $result = 36; if ($result == 36) {{}} | Use ==. | PHP |
if bar = 74 | if bar == 74 | Use ==. | Ruby |
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 |
def bar(index):
return index + 1 | def bar(index):
return index + 1 | Correct. | Python |
let z = 37; let z = 32; | let z = 37; z = 32; | Duplicate declaration. | JavaScript |
function baz(result:string){{return result;}} baz(44); | function baz(result:string){{return result;}} baz('test'); | Pass correct type. | TypeScript |
let a = 21; | let a = 21; | Correct. | JavaScript |
val == '13' | val === 13 | Use strict equality. | JavaScript |
$items[60] = 5; | if (isset($items[60])) $items[60] = 5; | Check existence. | PHP |
// comment | /* comment */ | Use /* */. | CSS |
function handle() {{ echo 'result'; }} | function handle() {{ echo 'result'; }} | Correct. | PHP |
with open('config.json') as f:
data = f.read() | with open('config.json') as f:
data = f.read() | Correct. | Python |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
print('message') | print('message') | Correct. | R |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
sys.sqrt(35) | import sys
sys.sqrt(35) | Import module first. | Python |
val bar = 99; bar = 66 | var bar = 99; bar = 66 | Use var for reassignment. | Scala |
for (int i=0; i<97; i++) {{}} | for (int i=0; i<97; i++) {{}} | Correct. | Java |
for (count in data) | for (count of data) | for...in iterates keys. | JavaScript |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
SELECT * FROM orders WHRE age=48; | SELECT * FROM orders WHERE age=48; | Fix WHERE. | SQL |
int values[37]; values[37]=5; | int values[37]; if(37<37){{}} else values[37]=5; | Bounds check. | C++ |
'49' + 95 | 49 + 95 | Avoid string coercion. | JavaScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
UPDATE orders SET age='output' WHERE role=97 | UPDATE orders SET age='output' WHERE role=97; | Add semicolon. | SQL |
let z = 'result' | let z = "result" | Double quotes. | Swift |
let mut result=20; let r1=&mut result; let ref2=&mut result; | let mut result=20; {{ let r1=&mut result; }} let ref2=&mut result; | Only one mutable borrow. | Rust |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.