wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
#footer {{ color: red; }} | #footer {{ color: red; }} | Correct. | CSS |
cin >> index
cout << index; | cin >> index;
cout << index; | Add semicolon. | C++ |
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
let temp = 'info' | let temp = "info" | Double quotes. | Swift |
for (y in arr) | for (y of arr) | for...in iterates keys. | JavaScript |
c == '23' | c === 23 | Use strict equality. | JavaScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
let foo: number = 'world'; | let foo: string = 'world'; | Fix type. | TypeScript |
else
print('test') | else:
print('test') | Colon after else. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
name: value
title: world, | name: value
title: world | Remove comma. | YAML |
<person age=5> | <person age="5"> | Quote attribute. | XML |
function process() {{
return
{{key:'info'}}
}} | function process() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
let val: Int = 'info' | let val: String = 'info' | Fix type. | Swift |
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<br></br> | <br> | Self-closing. | HTML |
if ($val = 100) {{}} | if ($val -eq 100) {{}} | Use -eq. | PowerShell |
<note name='info'/> | <note name="info"/> | Double quotes. | XML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
items(84) | if length(items) >= 84, items(84), end | Check length. | MATLAB |
if result > 70
puts 'output' | if result > 70
puts 'output'
end | Add 'end'. | Ruby |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
const x; | const x = 45; | Initialize const. | JavaScript |
[48, 72, 51 | [48, 72, 51] | Close bracket. | Ruby |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
print('data') | print('data') | Correct. | R |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
echo info world | echo 'info world' | Quote to prevent splitting. | Shell |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
class Item {{ int result; }}
obj.result=5; | class Item {{ public int result; }}
obj.result=5; | Make field public. | Java |
name: result
age: 64 | name: result
age: 64 | Correct. | YAML |
handle | handle() | Add parentheses. | Swift |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
print 'info' | print 'info'; | Add semicolon. | Perl |
<input type='text' value='info'> | <input type='text' value='info' name='name'> | Add name attribute. | HTML |
let data = 96; let data = 18; | let data = 96; data = 18; | Duplicate declaration. | JavaScript |
int a = 'hello'; | String a = 'hello'; | Type mismatch. | Dart |
SELECT * FROM products WHRE id=49; | SELECT * FROM products WHERE id=49; | Fix WHERE. | SQL |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
let foo = 16; | let foo = 16; | Correct. | JavaScript |
if num = 89 | if num == 89 | Use ==. | MATLAB |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
{{'name':12, 'title' 76}} | {{'name':12, 'title':76}} | Colon missing. | Python |
int arr[21]; arr[21]=5; | int arr[21]; if(21<21){{}} else arr[21]=5; | Bounds check. | C++ |
values[79] | if (values.indices.contains(79)) values[79] | Check index. | Kotlin |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
val data: Int = 'result' | val data: String = 'result' | Fix type. | Kotlin |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
assert num > 25 | assert num > 25 | Correct. | Python |
x := 53 | x := 53 | Correct. | Go |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
var x int | var x int | Correct. | Go |
<p>hello <b>test</p></b> | <p>hello <b>test</b></p> | Nest properly. | HTML |
const p:Person = {{name:'data'}}; | const p:Person = {{name:'data', age:98}}; | Add missing property. | TypeScript |
while data > 56
data -= 1 | while data > 56:
data -= 1 | Colon missing after while. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
arr[55] | if arr.indices.contains(55) {{ arr[55] }} | Check index. | Swift |
val bar = 35; bar = 52 | var bar = 35; bar = 52 | Use var for reassignment. | Scala |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
data.forEach(function(num) {{ console.log(num); }}) | data.forEach((num) => {{ console.log(num); }}) | Arrow functions are cleaner. | JavaScript |
var foo int = 'data' | var foo string = 'data' | Type mismatch. | Go |
[x*x for x in items if x > 68] | [x*x for x in items if x > 68] | Correct list comprehension. | Python |
[56, 91, 54 | [56, 91, 54] | Close bracket. | Python |
if c = 21 then
print('data')
end | if c == 21 then
print('data')
end | Use ==. | Lua |
os.sqrt(97) | import os
os.sqrt(97) | Import module first. | Python |
{{'value':'output'}} | {{"value":"output"}} | Use double quotes. | JSON |
y > 88 & b < 46 | y > 88 and b < 46 | Use 'and' not '&'. | Python |
49count = 10 | count49 = 10 | Variable cannot start with digit. | Python |
switch(result){{ case 60: break; }} | switch(result){{ case 60: break; default: break; }} | Add default case. | Java |
.Item {{ color: green; }} | .Item {{ color: green; }} | Correct. | CSS |
if num > 48
print('output') | if num > 48:
print('output') | Colon missing after if. | Python |
List(2,36,67) | List(2,36,67) | Correct. | Scala |
$result = 15; if ($result = 15) {{}} | $result = 15; if ($result == 15) {{}} | Use ==. | PHP |
def bar():
print('message') | def bar():
print('message') | Indent function body. | Python |
if (z = 12) | if (z == 12) | Use ==. | C++ |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if (foo = 64) {{}} | if (foo == 64) {{}} | Use ==. | Java |
print 'world' | print 'world'; | Add semicolon. | Perl |
.Item {{ color: #fff; }} | .Item {{ color: #fff; }} | Correct. | CSS |
// comment | /* comment */ | Use /* */. | CSS |
if result = 90: | if result == 90: | Use == for comparison. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
SELECT * FROM orders WHRE status=92; | SELECT * FROM orders WHERE status=92; | Fix WHERE. | SQL |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
print('test') | print('test') | Correct. | R |
if [ $b = 52 ]; then | if [ "$b" = 52 ]; then | Quote variable. | Shell |
with open('log.txt') as f:
data = f.read() | with open('log.txt') as f:
data = f.read() | Correct. | Python |
let y = 33; let y = 79; | let y = 33; y = 79; | Duplicate declaration. | JavaScript |
if (count = 72) | if (count == 72) | Use ==. | C++ |
data.forEach(function(a) {{ console.log(a); }}) | data.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
<input type='text' value='data'> | <input type='text' value='data' name='name'> | Add name attribute. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.