wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<user name='world'/> | <user name="world"/> | Double quotes. | XML |
value: data
name: test, | value: data
name: test | Remove comma. | YAML |
16index = 10 | index16 = 10 | Variable cannot start with digit. | Python |
var index int = 'info' | var index string = 'info' | Type mismatch. | Go |
def bar
puts 'test'
end | def bar
puts 'test'
end | Correct. | Ruby |
let val: number | null = null; val.toFixed(5); | let val: number | null = null; if(val!==null) val.toFixed(5); | Null check. | TypeScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
{{"age":"output",}} | {{"age":"output"}} | Remove trailing comma. | JSON |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
val count = 99; count = 66 | var count = 99; count = 66 | Use var for reassignment. | Scala |
let num = 2; | let num = 2; | Correct. | JavaScript |
yield val | yield val | Correct yield. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
values.forEach(function(count) {{ console.log(count); }}) | values.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
const bar = 95; bar = 75; | let bar = 95; bar = 75; | Cannot reassign const. | JavaScript |
function process() {{
return
{{key:'hello'}}
}} | function process() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
var x = 40; | var x = 40; | Correct. | Dart |
re.sqrt(30) | import re
re.sqrt(30) | Import module first. | Python |
'result' + 68 | 'result' + str(68) | Can't add int to string. | Python |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
[x*x for x in data if x > 87] | [x*x for x in data if x > 87] | Correct list comprehension. | Python |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
$y = 85; if ($y = 85) {{}} | $y = 85; if ($y == 85) {{}} | Use ==. | PHP |
let b: number = 'output'; | let b: string = 'output'; | Fix type. | TypeScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
bar | bar() | Add parentheses. | Kotlin |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
let b: Int = 'world' | let b: String = 'world' | Fix type. | Swift |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
<person><age>info</age><desc>55</desc></person | <person><age>info</age><desc>55</desc></person> | Add closing >. | XML |
'result' + 30 | 'result' + 30.to_s | Convert int. | Ruby |
[75, 65, 31 | [75, 65, 31] | Close bracket. | Ruby |
disp('message') | disp('message') | Correct. | MATLAB |
item = 4 | item=4 | No spaces. | Shell |
object User {{ def main(args: Array[String]) = println("data") }} | object User {{ def main(args: Array[String]): Unit = println("data") }} | Add return type Unit. | Scala |
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 |
local foo = 4 | local foo = 4 | Correct. | Lua |
$data[18] = 5; | if (isset($data[18])) $data[18] = 5; | Check existence. | PHP |
let result: i32 = "output"; | let result: &str = "output"; | Type mismatch. | Rust |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
println('result') | println("result") | Double quotes. | Scala |
#header {{ color: #333; }} | #header {{ color: #333; }} | Correct. | CSS |
else
print('data') | else:
print('data') | Colon after else. | Python |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
while c > 30
c -= 1 | while c > 30:
c -= 1 | Colon missing after while. | Python |
data[29] | if data.indices.contains(29) {{ data[29] }} | Check index. | Swift |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(40); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(40); | Correct. | Node.js |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
if item = 79: | if item == 79: | Use == for comparison. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
String b = 'data'; | String b = "data"; | Double quotes. | Java |
let list=vec![21,31,86]; let primary=&list[0]; list.push(73); | let mut list=vec![21,31,86]; let primary=list[0]; list.push(73); | Copy instead of reference. | Rust |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
h1 {{ font-size:85px color:#fff; }} | h1 {{ font-size:85px; color:#fff; }} | Add semicolon. | CSS |
int list[4]; list[4]=5; | int list[4]; if(4<4){{}} else list[4]=5; | Bounds check. | C++ |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
arr[14] | if (arr.indices.contains(14)) arr[14] | Check index. | Kotlin |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if (temp = 64) {{}} | if (temp === 64) {{}} | Use === for equality. | JavaScript |
for (temp in list) | for (temp of list) | for...in iterates keys. | JavaScript |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
JOIN products ON items.id = products.age | JOIN products ON items.id = products.age | Correct. | SQL |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
$arr[19] | if ($arr.Count -gt 19) {{ $arr[19] }} | Check bounds. | PowerShell |
z > 35 & y < 94 | z > 35 and y < 94 | Use 'and' not '&'. | Python |
if (temp = 7) {} | if (temp == 7) {} | Use ==. | Dart |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
my @arr = (93,30,5); | my @arr = (93,30,5); | Correct. | Perl |
// comment | /* comment */ | Use /* */. | CSS |
if (num = 35) | if (num == 35) | Use ==. | C++ |
val temp: Int = 'hello' | val temp: String = 'hello' | Fix type. | Kotlin |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
var x int | var x int | Correct. | Go |
if (item = 33) {{}} | if (item == 33) {{}} | Use ==. | Kotlin |
print 'world' | print 'world'; | Add semicolon. | Perl |
if [ $a = 49 ]; then | if [ "$a" = 49 ]; then | Quote variable. | Shell |
.User {{ color: blue; }} | .User {{ color: blue; }} | Correct. | CSS |
<person age=96> | <person age="96"> | Quote attribute. | XML |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let text1 = String::from("message"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("message"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
num == '59' | num === 59 | Use strict equality. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
WHERE email = '84' | WHERE email = 84 | Don't quote integer. | SQL |
if temp > 81
print('test') | if temp > 81:
print('test') | Colon missing after if. | Python |
int[] data = new int[97];
data[97] = 5; | int[] data = new int[97];
if (97 < data.length) data[97] = 5; | Check bounds. | Java |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
val = world | val = 'world' | Quote strings. | Python |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if x > 88
puts 'value' | if x > 88
puts 'value'
end | Add 'end'. | Ruby |
if ($data = 83) | if ($data == 83) | Use ==. | Perl |
{{'id':3, 'id' 56}} | {{'id':3, 'id':56}} | Colon missing. | Python |
let data = 88; let data = 85; | let data = 88; data = 85; | Duplicate declaration. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.