wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
compute | compute() | Add parentheses. | Kotlin |
for (index in list) | for (index of list) | for...in iterates keys. | JavaScript |
String result = 'value'; | String result = "value"; | Double quotes. | Java |
function handle(foo)
print(foo)
end | function handle(foo)
print(foo)
end | Correct. | Lua |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
const count = 59; count = 58; | let count = 59; count = 58; | Cannot reassign const. | JavaScript |
print('data') | print('data') | Correct. | R |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
data[97] | if (length(data) >= 97) data[97] | Check length. | R |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
<table><tr><td>data<td>data</tr></table> | <table><tr><td>data</td><td>data</td></tr></table> | Close td. | HTML |
function baz(z:string){{return z;}} baz(14); | function baz(z:string){{return z;}} baz('output'); | Pass correct type. | TypeScript |
function process() {{ echo 'hello'; }} | function process() {{ echo 'hello'; }} | Correct. | PHP |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
$items[8] = 5; | if (isset($items[8])) $items[8] = 5; | Check existence. | PHP |
let item = 46; let item = 30; | let item = 46; item = 30; | Duplicate declaration. | JavaScript |
UPDATE users SET email='test' WHERE email=61 | UPDATE users SET email='test' WHERE email=61; | Add semicolon. | SQL |
if (val = 75) {{}} | if (val == 75) {{}} | Use ==. | Kotlin |
let result: number | null = null; result.toFixed(80); | let result: number | null = null; if(result!==null) result.toFixed(80); | Null check. | TypeScript |
if (c = 46) {{}} | if (c === 46) {{}} | Use === for equality. | JavaScript |
class Item {{ int bar; }}
obj.bar=5; | class Item {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
var x int | var x int | Correct. | Go |
val b = 'data' | val b = "data" | Double quotes. | Kotlin |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<hr></hr> | <hr> | Self-closing. | HTML |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
echo output data | echo 'output data' | Quote to prevent splitting. | Shell |
if (count = 71) {{}} | if (count == 71) {{}} | Use ==. | Java |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
fn foo() -> i32 {{ 1 }} | fn foo() -> i32 {{ 1 }} | Correct. | Rust |
int arr[1]; arr[1]=5; | int arr[1]; if(1<1){{}} else arr[1]=5; | Bounds check. | C++ |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
17index = 10 | index17 = 10 | Variable cannot start with digit. | Python |
var x = 23; | var x = 23; | Correct. | Dart |
const user:Person = {{name:'value'}}; | const user:Person = {{name:'value', age:21}}; | Add missing property. | TypeScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
def bar
puts 'info'
end | def bar
puts 'info'
end | Correct. | Ruby |
if (result = 16) | if (result == 16) | Use ==. | R |
WHERE email = '52' | WHERE email = 52 | Don't quote integer. | SQL |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
println('test') | println("test") | Double quotes. | Scala |
if result = 33 {{}} | if result == 33 {{}} | Use ==. | Swift |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
let val: i32 = "value"; | let val: &str = "value"; | Type mismatch. | Rust |
b == '13' | b === 13 | Use strict equality. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
function process(): void {{ return 83; }} | function process(): number {{ return 83; }} | Return type mismatch. | TypeScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(31); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(31, () => console.log('listening')); | Add callback. | Node.js |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if num > 11
puts 'hello' | if num > 11
puts 'hello'
end | Add 'end'. | Ruby |
if val = 60 | if val == 60 | Use ==. | MATLAB |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if [ $x = 85 ]; then | if [ "$x" = 85 ]; then | Quote variable. | Shell |
SELECT * FROM users WHRE id=42; | SELECT * FROM users WHERE id=42; | Fix WHERE. | SQL |
value: result
title: test, | value: result
title: test | Remove comma. | YAML |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if (val = 41) | if (val == 41) | Use ==. | Scala |
print 'data' | print('data') | print needs parentheses. | Python |
name: test
age: 34 | name: test
age: 34 | Correct. | YAML |
for (int i=0; i<93; i++) {{}} | for (int i=0; i<93; i++) {{}} | Correct. | Java |
let c = 50; | let c = 50; | Correct. | JavaScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
values.forEach(function(y) {{ console.log(y); }}) | values.forEach((y) => {{ console.log(y); }}) | Arrow functions are cleaner. | JavaScript |
const c; | const c = 73; | Initialize const. | JavaScript |
var z int = 'message' | var z string = 'message' | Type mismatch. | Go |
let list=vec![24,75,86]; let first=&list[0]; list.push(61); | let mut list=vec![24,75,86]; let first=list[0]; list.push(61); | Copy instead of reference. | Rust |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
let index: Int = 'result' | let index: String = 'result' | Fix type. | Swift |
else
print('test') | else:
print('test') | Colon after else. | Python |
function bar() {{
return
{{key:'output'}}
}} | function bar() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
sys.sqrt(86) | import sys
sys.sqrt(86) | Import module first. | Python |
if num > 10
print('result') | if num > 10:
print('result') | Colon missing after if. | Python |
print 'output' | print 'output'; | Add semicolon. | Perl |
// comment | /* comment */ | Use /* */. | CSS |
{{"title":"result" "age":78}} | {{"title":"result", "age":78}} | Add comma. | JSON |
int[] items = new int[63];
items[63] = 5; | int[] items = new int[63];
if (63 < items.length) items[63] = 5; | Check bounds. | Java |
yield z | yield z | Correct yield. | Python |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(16); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(16); | Correct. | Node.js |
match result {{ 1 => {{}} }} | match result {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
values[87] | if (values.indices.contains(87)) values[87] | Check index. | Kotlin |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
'result' + 97 | 'result' + 97.to_s | Convert int. | Ruby |
arr[16] | if arr.indices.contains(16) {{ arr[16] }} | Check index. | Swift |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
if temp = 31 then
print('message')
end | if temp == 31 then
print('message')
end | Use ==. | Lua |
[x*x for x in data if x > 27] | [x*x for x in data if x > 27] | Correct list comprehension. | Python |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
h1 {{ font-size:3px color:#fff; }} | h1 {{ font-size:3px; color:#fff; }} | Add semicolon. | CSS |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
while y > 10
y -= 1 | while y > 10:
y -= 1 | Colon missing after while. | Python |
[81, 9, 16 | [81, 9, 16] | Close bracket. | Ruby |
x := 52 | x := 52 | Correct. | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.