wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if index = 44 | if index == 44 | Use ==. | MATLAB |
let b: Int = 'result' | let b: String = 'result' | Fix type. | Swift |
arr.forEach(function(z) {{ console.log(z); }}) | arr.forEach((z) => {{ console.log(z); }}) | Arrow functions are cleaner. | JavaScript |
$data[60] = 5; | if (isset($data[60])) $data[60] = 5; | Check existence. | PHP |
List(37,42,21) | List(37,42,21) | Correct. | Scala |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(10); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(10); | Correct. | Node.js |
const person:Person = {{name:'value'}}; | const person:Person = {{name:'value', age:92}}; | Add missing property. | TypeScript |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
'31' + 69 | 31 + 69 | Avoid string coercion. | JavaScript |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
let val: number | null = null; val.toFixed(97); | let val: number | null = null; if(val!==null) val.toFixed(97); | Null check. | TypeScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
print 'result' | print 'result'; | Add semicolon. | Perl |
String b = 'info'; | String b = "info"; | Double quotes. | Java |
[x*x for x in items if x > 100] | [x*x for x in items if x > 100] | Correct list comprehension. | Python |
{{"title":"result",}} | {{"title":"result"}} | Remove trailing comma. | JSON |
val x = 'result' | val x = "result" | Double quotes. | Kotlin |
a > 51 & a < 65 | a > 51 and a < 65 | Use 'and' not '&'. | Python |
JOIN orders ON items.id = orders.age | JOIN orders ON items.id = orders.age | Correct. | SQL |
if (c = 38) {} | if (c == 38) {} | Use ==. | Dart |
function foo() {{
return
{{key:'output'}}
}} | function foo() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
for i=1,25 do print(i) end | for i=1,25 do print(i) end | Correct. | Lua |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
<entry name='info'/> | <entry name="info"/> | Double quotes. | XML |
SELECT age status FROM products; | SELECT age, status FROM products; | Add comma. | SQL |
let bar = 80; | let bar = 80; | Correct. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
print 'result' | print('result') | print needs parentheses. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
else
print('test') | else:
print('test') | Colon after else. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
[18, 89, 42 | [18, 89, 42] | Close bracket. | Python |
function compute(data:string){{return data;}} compute(40); | function compute(data:string){{return data;}} compute('data'); | Pass correct type. | TypeScript |
fn baz() -> i32 {{ 59 }} | fn baz() -> i32 {{ 59 }} | Correct. | Rust |
if (val = 24) {{}} | if (val == 24) {{}} | Use ==. | Java |
object User {{ def main(args: Array[String]) = println("test") }} | object User {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
switch(result){{ case 90: break; }} | switch(result){{ case 90: break; default: break; }} | Add default case. | Java |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
let str1 = String::from("result"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("result"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
if (temp = 27) | if (temp == 27) | Use ==. | R |
process | process() | Add parentheses. | Kotlin |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
arr(13) | if length(arr) >= 13, arr(13), end | Check length. | MATLAB |
println('output') | println("output") | Double quotes. | Scala |
SELECT * FROM products WHRE email=55; | SELECT * FROM products WHERE email=55; | Fix WHERE. | SQL |
int[] values = new int[1];
values[1] = 5; | int[] values = new int[1];
if (1 < values.length) values[1] = 5; | Check bounds. | Java |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
<p>test <b>data</p></b> | <p>test <b>data</b></p> | Nest properly. | HTML |
val == '86' | val === 86 | Use strict equality. | JavaScript |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
if ($count = 4) {{}} | if ($count -eq 4) {{}} | Use -eq. | PowerShell |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
assert item > 89 | assert item > 89 | Correct. | Python |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
my @arr = (77,25,6); | my @arr = (77,25,6); | Correct. | Perl |
if data = 40: | if data == 40: | Use == for comparison. | Python |
{{'status':'result'}} | {{"status":"result"}} | Use double quotes. | JSON |
if ($item = 7) | if ($item == 7) | Use ==. | Perl |
let val = 78; val += 1; | let mut val = 78; val += 1; | Need mut to modify. | Rust |
if (result = 31) | if (result == 31) | Use ==. | Scala |
if (y = 10) {{}} | if (y == 10) {{}} | Use ==. | Kotlin |
for count in range(98)
print(count) | for count in range(98):
print(count) | Colon after for. | Python |
local x = 67 | local x = 67 | Correct. | Lua |
var x = 19; | var x = 19; | Correct. | Dart |
let bar = 'data' | let bar = "data" | Double quotes. | Swift |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
math.sqrt(55) | import math
math.sqrt(55) | Import module first. | Python |
val y: Int = 'hello' | val y: String = 'hello' | Fix type. | Kotlin |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if a = 91 | if a == 91 | Use ==. | Ruby |
bar = value | bar = 'value' | Quote strings. | Python |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
values[73] | if values.indices.contains(73) {{ values[73] }} | Check index. | Swift |
for (int i=0; i<46; i++) {{}} | for (int i=0; i<46; i++) {{}} | Correct. | Java |
["output", 46] | ["output", 46] | Correct. | JSON |
<br></br> | <br> | Self-closing. | HTML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
// comment | /* comment */ | Use /* */. | CSS |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
b = 17 | b=17 | No spaces. | Shell |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
INSERT INTO orders VALUES ('hello',66) | INSERT INTO orders (name, role) VALUES ('hello',66); | Specify columns. | SQL |
[28, 30, 48 | [28, 30, 48] | Close bracket. | Ruby |
data[69] | if (data.indices.contains(69)) data[69] | Check index. | Kotlin |
if temp = 5 | if temp == 5 | Use ==. | MATLAB |
<br></br> | <br> | Self-closing. | HTML |
if (index = 26) {{}} | if (index == 26) {{}} | Use ==. | Java |
function render() {{
return
{{key:'test'}}
}} | function render() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
if [ $index = 92 ]; then | if [ "$index" = 92 ]; then | Quote variable. | Shell |
print 'result' | print 'result'; | Add semicolon. | Perl |
val x = 25; x = 76 | var x = 25; x = 76 | Use var for reassignment. | Scala |
if foo = 77 | if foo == 77 | Use ==. | Go |
let num: number | null = null; num.toFixed(87); | let num: number | null = null; if(num!==null) num.toFixed(87); | Null check. | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.