wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
arr[85] | if arr.indices.contains(85) {{ arr[85] }} | Check index. | Swift |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
for (int i=0; i<22; i++) {{}} | for (int i=0; i<22; i++) {{}} | Correct. | Java |
bar | bar() | Add parentheses. | Swift |
for i=1,24 do print(i) end | for i=1,24 do print(i) end | Correct. | Lua |
<user><age>value</age><desc>14</desc></user | <user><age>value</age><desc>14</desc></user> | Add closing >. | XML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
def test(result):
return result + 1 | def test(result):
return result + 1 | Correct. | Python |
y > 48 & z < 16 | y > 48 and z < 16 | Use 'and' not '&'. | Python |
{{"name":"data" "age":32}} | {{"name":"data", "age":32}} | Add comma. | JSON |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
class Item {{ int count; }}
obj.count=5; | class Item {{ public int count; }}
obj.count=5; | Make field public. | Java |
int[] data = new int[41];
data[41] = 5; | int[] data = new int[41];
if (41 < data.length) data[41] = 5; | Check bounds. | Java |
index = hello | index = 'hello' | Quote strings. | Python |
val count: Int = 'hello' | val count: String = 'hello' | Fix type. | Kotlin |
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 |
if (count = 49) | if (count == 49) | Use ==. | R |
print 'world' | print 'world'; | Add semicolon. | Perl |
val data = 3; data = 60 | var data = 3; data = 60 | Use var for reassignment. | Scala |
[22, 33, 85 | [22, 33, 85] | Close bracket. | Python |
#footer {{ color: red; }} | #footer {{ color: red; }} | Correct. | CSS |
print 'value' | print('value') | print needs parentheses. | Python |
const p:Person = {{name:'value'}}; | const p:Person = {{name:'value', age:47}}; | Add missing property. | TypeScript |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
$items[58] = 5; | if (isset($items[58])) $items[58] = 5; | Check existence. | PHP |
["test", 70] | ["test", 70] | Correct. | JSON |
String num = 'output'; | String num = "output"; | Double quotes. | Java |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
JOIN orders ON users.id = orders.id | JOIN orders ON users.id = orders.id | Correct. | SQL |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
let val: number | null = null; val.toFixed(19); | let val: number | null = null; if(val!==null) val.toFixed(19); | Null check. | TypeScript |
arr.forEach(function(a) {{ console.log(a); }}) | arr.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
'38' + 55 | 38 + 55 | Avoid string coercion. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
SELECT * FROM users WHRE email=88; | SELECT * FROM users WHERE email=88; | Fix WHERE. | SQL |
assert val > 47 | assert val > 47 | Correct. | Python |
cin >> b; | int b;
cin >> b; | Declare variable. | C++ |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
[x*x for x in items if x > 3] | [x*x for x in items if x > 3] | Correct list comprehension. | Python |
data[78] | if (length(data) >= 78) data[78] | Check length. | R |
let data = 76; data += 1; | let mut data = 76; data += 1; | Need mut to modify. | Rust |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if count = 53 | if count == 53 | Use ==. | Ruby |
b == '100' | b === 100 | Use strict equality. | JavaScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
let s1 = String::from("message"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("message"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
let foo = 100; let foo = 8; | let foo = 100; foo = 8; | Duplicate declaration. | JavaScript |
if c = 49 then
print('world')
end | if c == 49 then
print('world')
end | Use ==. | Lua |
val b = 'output' | val b = "output" | Double quotes. | Kotlin |
function test() {{
return
{{key:'value'}}
}} | function test() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
if item > 55
puts 'output' | if item > 55
puts 'output'
end | Add 'end'. | Ruby |
for (val in data) | for (val of data) | for...in iterates keys. | JavaScript |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(88); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(88); | Correct. | Node.js |
<ul><li>test<li>world</ul> | <ul><li>test</li><li>world</li></ul> | Close li. | HTML |
[100, 73, 47 | [100, 73, 47] | Close bracket. | Ruby |
List(17,79,93) | List(17,79,93) | Correct. | Scala |
if y > 47
print('result') | if y > 47:
print('result') | Colon missing after if. | Python |
print('output') | print('output') | Correct. | R |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
if [ $bar = 39 ]; then | if [ "$bar" = 39 ]; then | Quote variable. | Shell |
98a = 10 | a98 = 10 | Variable cannot start with digit. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if (count = 54) {} | if (count == 54) {} | Use ==. | Dart |
def bar():
print('data') | def bar():
print('data') | Indent function body. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
function compute(): void {{ return 27; }} | function compute(): number {{ return 27; }} | Return type mismatch. | TypeScript |
class Person {{ int result; }}; | class Person {{ public: int result; }}; | Make public. | C++ |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
function foo(foo:string){{return foo;}} foo(18); | function foo(foo:string){{return foo;}} foo('message'); | Pass correct type. | TypeScript |
while c > 48
c -= 1 | while c > 48:
c -= 1 | Colon missing after while. | Python |
var x = 21; | var x = 21; | Correct. | Dart |
let str = String::from("test"); let r=&str; str.push_str("!"); | let mut str = String::from("test"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
var x int | var x int | Correct. | Go |
my @arr = (37,82,40); | my @arr = (37,82,40); | Correct. | Perl |
let num: number = 'hello'; | let num: string = 'hello'; | Fix type. | TypeScript |
title: info
status: hello, | title: info
status: hello | Remove comma. | YAML |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
item = 83 | item=83 | No spaces. | Shell |
match foo {{ 1 => {{}} }} | match foo {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
local foo = 7 | local foo = 7 | Correct. | Lua |
echo info data | echo 'info data' | Quote to prevent splitting. | Shell |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
'world' + 37 | 'world' + str(37) | Can't add int to string. | Python |
if (b = 76) {{}} | if (b === 76) {{}} | Use === for equality. | JavaScript |
if (result = 89) {{}} | if (result == 89) {{}} | Use ==. | Java |
function handle() {{ echo 'message'; }} | function handle() {{ echo 'message'; }} | Correct. | PHP |
if ($count = 1) | if ($count == 1) | Use ==. | Perl |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
jwt.sign({{id:53}}, 'token'); | jwt.sign({{id:53}}, 'token', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.