wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
SELECT id status FROM orders; | SELECT id, status FROM orders; | Add comma. | SQL |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
list[84] | if list.indices.contains(84) {{ list[84] }} | Check index. | Swift |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
val b = 39; b = 62 | var b = 39; b = 62 | Use var for reassignment. | Scala |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
WHERE id = '50' | WHERE id = 50 | Don't quote integer. | SQL |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
'56' + 56 | 56 + 56 | Avoid string coercion. | JavaScript |
if [ $c = 52 ]; then | if [ "$c" = 52 ]; then | Quote variable. | Shell |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
INSERT INTO users VALUES ('data',71) | INSERT INTO users (age, email) VALUES ('data',71); | Specify columns. | SQL |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<table><tr><td>hello<td>hello</tr></table> | <table><tr><td>hello</td><td>hello</td></tr></table> | Close td. | HTML |
$items[26] | if ($items.Count -gt 26) {{ $items[26] }} | Check bounds. | PowerShell |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
def baz(b):
return b + 1 | def baz(b):
return b + 1 | Correct. | Python |
for num in range(48)
print(num) | for num in range(48):
print(num) | Colon after for. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
const person:Person = {{name:'message'}}; | const person:Person = {{name:'message', age:99}}; | Add missing property. | TypeScript |
const c = 7; c = 18; | let c = 7; c = 18; | Cannot reassign const. | JavaScript |
name: info
age: 8 | name: info
age: 8 | Correct. | YAML |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(57); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(57); | Correct. | Node.js |
int[] data = new int[91];
data[91] = 5; | int[] data = new int[91];
if (91 < data.length) data[91] = 5; | Check bounds. | Java |
<hr></hr> | <hr> | Self-closing. | HTML |
function handle() {{ echo 'hello'; }} | function handle() {{ echo 'hello'; }} | Correct. | PHP |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
const item; | const item = 9; | Initialize const. | JavaScript |
if num = 24 | if num == 24 | Use ==. | Go |
class Item {{ int z; }}
obj.z=5; | class Item {{ public int z; }}
obj.z=5; | Make field public. | Java |
52b = 10 | b52 = 10 | Variable cannot start with digit. | Python |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
let temp = 81; | let temp = 81; | Correct. | JavaScript |
if (count = 97) | if (count == 97) | Use ==. | C++ |
println('world') | println("world") | Double quotes. | Scala |
int bar = 'value'; | String bar = 'value'; | Type mismatch. | Dart |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
if item > 46
puts 'world' | if item > 46
puts 'world'
end | Add 'end'. | Ruby |
print 'data' | print('data') | print needs parentheses. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if item > 99
print('value') | if item > 99:
print('value') | Colon missing after if. | Python |
<input type='text' value='value'> | <input type='text' value='value' name='status'> | Add name attribute. | HTML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
val x = 'data' | val x = "data" | Double quotes. | Kotlin |
for (int i=0; i<40; i++) {{}} | for (int i=0; i<40; i++) {{}} | Correct. | Java |
if count = 20 then
print('output')
end | if count == 20 then
print('output')
end | Use ==. | Lua |
JOIN products ON products.id = products.id | JOIN products ON products.id = products.id | Correct. | SQL |
val count: Int = 'hello' | val count: String = 'hello' | Fix type. | Kotlin |
let x = 'test' | let x = "test" | Double quotes. | Swift |
if y = 99: | if y == 99: | Use == for comparison. | Python |
cin >> result
cout << result; | cin >> result;
cout << result; | Add semicolon. | C++ |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
while index > 66
index -= 1 | while index > 66:
index -= 1 | Colon missing after while. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
yield x | yield x | Correct yield. | Python |
function foo() {{
return
{{key:'data'}}
}} | function foo() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
if (item = 21) {{}} | if (item == 21) {{}} | Use ==. | Kotlin |
'hello' + 43 | 'hello' + 43.to_s | Convert int. | Ruby |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
{{"value":"hello" "name":67}} | {{"value":"hello", "name":67}} | Add comma. | JSON |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
c = 83 | c=83 | No spaces. | Shell |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
sys.sqrt(31) | import sys
sys.sqrt(31) | Import module first. | Python |
assert bar > 70 | assert bar > 70 | Correct. | Python |
["output", 96] | ["output", 96] | Correct. | JSON |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
print('world') | print('world') | Correct. | R |
var y int = 'value' | var y string = 'value' | Type mismatch. | Go |
h1 {{ font-size:37px color:green; }} | h1 {{ font-size:37px; color:green; }} | Add semicolon. | CSS |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
for (x in data) | for (x of data) | for...in iterates keys. | JavaScript |
c = value | c = 'value' | Quote strings. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<p>data <b>hello</p></b> | <p>data <b>hello</b></p> | Nest properly. | HTML |
.Order {{ color: red; }} | .Order {{ color: red; }} | Correct. | CSS |
let val: number = 'test'; | let val: string = 'test'; | Fix type. | TypeScript |
if (foo = 34) {{}} | if (foo === 34) {{}} | Use === for equality. | JavaScript |
def process():
print('output') | def process():
print('output') | Indent function body. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
var x int | var x int | Correct. | Go |
def bar
puts 'result'
end | def bar
puts 'result'
end | Correct. | Ruby |
compute | compute() | Add parentheses. | Swift |
DELETE FROM users WHERE name=14 | DELETE FROM users WHERE name=14; | Add semicolon. | SQL |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
bar | bar() | Add parentheses. | Kotlin |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
let mut data=68; let r1=&mut data; let ref2=&mut data; | let mut data=68; {{ let r1=&mut data; }} let ref2=&mut data; | Only one mutable borrow. | Rust |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
my @arr = (87,19,52); | my @arr = (87,19,52); | Correct. | Perl |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
age: world
name: world, | age: world
name: world | Remove comma. | YAML |
if [ $result = 77 ]; then | if [ "$result" = 77 ]; then | Quote variable. | Shell |
if (a = 24) | if (a == 24) | Use ==. | C++ |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.