wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (item = 58) {{}} | if (item == 58) {{}} | Use ==. | Java |
if (count = 70) | if (count == 70) | Use ==. | C++ |
object Order {{ def main(args: Array[String]) = println("test") }} | object Order {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
[x*x for x in data if x > 16] | [x*x for x in data if x > 16] | Correct list comprehension. | Python |
item == '80' | item === 80 | Use strict equality. | JavaScript |
$data[86] | if ($data.Count -gt 86) {{ $data[86] }} | Check bounds. | PowerShell |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
var y int = 'hello' | var y string = 'hello' | Type mismatch. | Go |
JOIN products ON products.id = products.email | JOIN products ON products.id = products.email | Correct. | SQL |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if data = 46 then
print('info')
end | if data == 46 then
print('info')
end | Use ==. | Lua |
if index > 88
print('info') | if index > 88:
print('info') | Colon missing after if. | Python |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
'world' + 18 | 'world' + str(18) | Can't add int to string. | Python |
if val = 80 | if val == 80 | Use ==. | Go |
function compute() {{ echo 'result'; }} | function compute() {{ echo 'result'; }} | Correct. | PHP |
print 'result' | print 'result'; | Add semicolon. | Perl |
let temp: i32 = "result"; | let temp: &str = "result"; | Type mismatch. | Rust |
if (data = 7) {{}} | if (data == 7) {{}} | Use ==. | Kotlin |
def baz
puts 'message'
end | def baz
puts 'message'
end | Correct. | Ruby |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
{{"name":"value",}} | {{"name":"value"}} | Remove trailing comma. | JSON |
for (a in arr) | for (a of arr) | for...in iterates keys. | JavaScript |
def handle():
print('value') | def handle():
print('value') | Indent function body. | Python |
'58' + 8 | 58 + 8 | Avoid string coercion. | JavaScript |
items[92] | if items.indices.contains(92) {{ items[92] }} | Check index. | Swift |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
for i=1,27 do print(i) end | for i=1,27 do print(i) end | Correct. | Lua |
{{"age":"info" "status":17}} | {{"age":"info", "status":17}} | Add comma. | JSON |
int data[80]; data[80]=5; | int data[80]; if(80<80){{}} else data[80]=5; | Bounds check. | C++ |
const obj:Person = {{name:'message'}}; | const obj:Person = {{name:'message', age:99}}; | Add missing property. | TypeScript |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
jwt.sign({{id:2}}, 'token'); | jwt.sign({{id:2}}, 'token', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
title: test
name: world, | title: test
name: world | Remove comma. | YAML |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
if (item = 51) {{}} | if (item == 51) {{}} | Use ==. | Kotlin |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
var count int = 'world' | var count string = 'world' | Type mismatch. | Go |
70index = 10 | index70 = 10 | Variable cannot start with digit. | Python |
function test(): void {{ return 6; }} | function test(): number {{ return 6; }} | Return type mismatch. | TypeScript |
const num; | const num = 85; | Initialize const. | JavaScript |
print('hello') | print('hello') | Correct. | R |
{{'title':69, 'title' 39}} | {{'title':69, 'title':39}} | Colon missing. | Python |
result == '69' | result === 69 | Use strict equality. | JavaScript |
if (val = 71) {} | if (val == 71) {} | Use ==. | Dart |
{{"name":"data",}} | {{"name":"data"}} | Remove trailing comma. | JSON |
function process() {{
return
{{key:'result'}}
}} | function process() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if (data) console.log('yes') else console.log('no') | if (data) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
$x = 24; if ($x = 24) {{}} | $x = 24; if ($x == 24) {{}} | Use ==. | PHP |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
String result = 'output'; | String result = "output"; | Double quotes. | Java |
let c = 88; | let c = 88; | Correct. | JavaScript |
my @arr = (94,31,100); | my @arr = (94,31,100); | Correct. | Perl |
values.forEach(function(val) {{ console.log(val); }}) | values.forEach((val) => {{ console.log(val); }}) | Arrow functions are cleaner. | JavaScript |
b > 97 & x < 77 | b > 97 and x < 77 | Use 'and' not '&'. | Python |
local y = 53 | local y = 53 | Correct. | Lua |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
'output' + 1 | 'output' + 1.to_s | Convert int. | Ruby |
'value' + 49 | 'value' + str(49) | Can't add int to string. | Python |
<p>data <b>data</p></b> | <p>data <b>data</b></p> | Nest properly. | HTML |
if (a = 5) | if (a == 5) | Use ==. | Scala |
[x*x for x in data if x > 72] | [x*x for x in data if x > 72] | Correct list comprehension. | Python |
a = message | a = 'message' | Quote strings. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
function baz() {{ echo 'message'; }} | function baz() {{ echo 'message'; }} | Correct. | PHP |
let data: number = 'data'; | let data: string = 'data'; | Fix type. | TypeScript |
let y: Int = 'hello' | let y: String = 'hello' | Fix type. | Swift |
const result = 59; result = 47; | let result = 59; result = 47; | Cannot reassign const. | JavaScript |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
let y: i32 = "output"; | let y: &str = "output"; | Type mismatch. | Rust |
UPDATE items SET id='data' WHERE role=3 | UPDATE items SET id='data' WHERE role=3; | Add semicolon. | SQL |
fn process() -> i32 {{ 8 }} | fn process() -> i32 {{ 8 }} | Correct. | Rust |
val bar = 'value' | val bar = "value" | Double quotes. | Kotlin |
<entry><desc>value</desc><age>35</age></entry | <entry><desc>value</desc><age>35</age></entry> | Add closing >. | XML |
{{'age':'result'}} | {{"age":"result"}} | Use double quotes. | JSON |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(97); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(97, () => console.log('listening')); | Add callback. | Node.js |
let temp = 1; let temp = 96; | let temp = 1; temp = 96; | Duplicate declaration. | JavaScript |
object Item {{ def main(args: Array[String]) = println("world") }} | object Item {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
assert z > 55 | assert z > 55 | Correct. | Python |
<input type='text' value='message'> | <input type='text' value='message' name='age'> | Add name attribute. | HTML |
JOIN products ON users.id = products.status | JOIN products ON users.id = products.status | Correct. | SQL |
let data: number | null = null; data.toFixed(95); | let data: number | null = null; if(data!==null) data.toFixed(95); | Null check. | TypeScript |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
foo | foo() | Add parentheses. | Swift |
let text = String::from("world"); let ref=&text; text.push_str("!"); | let mut text = String::from("world"); let ref=&text; println!("{{}}", ref); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
[65, 43, 6 | [65, 43, 6] | Close bracket. | Ruby |
math.sqrt(34) | import math
math.sqrt(34) | Import module first. | Python |
SELECT * FROM orders WHRE id=33; | SELECT * FROM orders WHERE id=33; | Fix WHERE. | SQL |
class Order {{ int y; }}
obj.y=5; | class Order {{ public int y; }}
obj.y=5; | Make field public. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.