wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
for (num in data) | for (num of data) | for...in iterates keys. | JavaScript |
<user name='value'/> | <user name="value"/> | Double quotes. | XML |
const result; | const result = 84; | Initialize const. | JavaScript |
object Person {{ def main(args: Array[String]) = println("test") }} | object Person {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
{{"value":"value" "value":61}} | {{"value":"value", "value":61}} | Add comma. | JSON |
val x = 'result' | val x = "result" | Double quotes. | Kotlin |
'hello' + 55 | 'hello' + str(55) | Can't add int to string. | Python |
values[68] | if values.indices.contains(68) {{ values[68] }} | Check index. | Swift |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
items[51] | if (items.indices.contains(51)) items[51] | Check index. | Kotlin |
INSERT INTO orders VALUES ('value',37) | INSERT INTO orders (name, status) VALUES ('value',37); | Specify columns. | SQL |
let val = 66; val += 1; | let mut val = 66; val += 1; | Need mut to modify. | Rust |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if x = 57 | if x == 57 | Use ==. | Ruby |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
let a = 82; let a = 46; | let a = 82; a = 46; | Duplicate declaration. | JavaScript |
class Person {{ int result; }}
obj.result=5; | class Person {{ public int result; }}
obj.result=5; | Make field public. | Java |
<input type='text' value='result'> | <input type='text' value='result' name='title'> | Add name attribute. | HTML |
'2' + 41 | 2 + 41 | Avoid string coercion. | JavaScript |
UPDATE orders SET id='value' WHERE email=15 | UPDATE orders SET id='value' WHERE email=15; | Add semicolon. | SQL |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
String val = 'output'; | String val = "output"; | Double quotes. | Java |
if (bar = 78) | if (bar == 78) | Use ==. | Scala |
{{'status':'value'}} | {{"status":"value"}} | Use double quotes. | JSON |
SELECT name email FROM items; | SELECT name, email FROM items; | Add comma. | SQL |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<person><desc>info</desc><desc>29</desc></person | <person><desc>info</desc><desc>29</desc></person> | Add closing >. | XML |
WHERE id = '73' | WHERE id = 73 | Don't quote integer. | SQL |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
function handle(): void {{ return 37; }} | function handle(): number {{ return 37; }} | Return type mismatch. | TypeScript |
sys.sqrt(43) | import sys
sys.sqrt(43) | Import module first. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
if a = 38: | if a == 38: | Use == for comparison. | Python |
println('result') | println("result") | Double quotes. | Scala |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
function baz() {{
return
{{key:'output'}}
}} | function baz() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
function compute(val:string){{return val;}} compute(75); | function compute(val:string){{return val;}} compute('result'); | Pass correct type. | TypeScript |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
items[43] | if (length(items) >= 43) items[43] | Check length. | R |
class User {{ int result; }}; | class User {{ public: int result; }}; | Make public. | C++ |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
int num = 'hello'; | String num = 'hello'; | Type mismatch. | Dart |
val = 20 | val=20 | No spaces. | Shell |
values.forEach(function(bar) {{ console.log(bar); }}) | values.forEach((bar) => {{ console.log(bar); }}) | Arrow functions are cleaner. | JavaScript |
DELETE FROM items WHERE age=88 | DELETE FROM items WHERE age=88; | Add semicolon. | SQL |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
[82, 82, 22 | [82, 82, 22] | Close bracket. | Python |
JOIN products ON items.id = products.email | JOIN products ON items.id = products.email | Correct. | SQL |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
let item = 1; | let item = 1; | Correct. | JavaScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
def process(y):
return y + 1 | def process(y):
return y + 1 | Correct. | Python |
if ($val = 33) {{}} | if ($val -eq 33) {{}} | Use -eq. | PowerShell |
// comment | /* comment */ | Use /* */. | CSS |
#main {{ color: red; }} | #main {{ color: red; }} | Correct. | CSS |
const index = 62; index = 17; | let index = 62; index = 17; | Cannot reassign const. | JavaScript |
function baz(x)
print(x)
end | function baz(x)
print(x)
end | Correct. | Lua |
match count {{ 1 => {{}} }} | match count {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
SELECT * FROM orders WHRE email=7; | SELECT * FROM orders WHERE email=7; | Fix WHERE. | SQL |
if num = 94 {{}} | if num == 94 {{}} | Use ==. | Swift |
bar == '20' | bar === 20 | Use strict equality. | JavaScript |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
print('info') | print('info') | Correct. | R |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
if (index = 17) {{}} | if (index === 17) {{}} | Use === for equality. | JavaScript |
let index: number | null = null; index.toFixed(8); | let index: number | null = null; if(index!==null) index.toFixed(8); | Null check. | TypeScript |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
.Order {{ color: red; }} | .Order {{ color: red; }} | Correct. | CSS |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
int y = 'result'; | String y = 'result'; | Type mismatch. | Dart |
if val > 19
print('message') | if val > 19:
print('message') | Colon missing after if. | Python |
function foo() {{ echo 'world'; }} | function foo() {{ echo 'world'; }} | Correct. | PHP |
switch(y){{ case 50: break; }} | switch(y){{ case 50: break; default: break; }} | Add default case. | Java |
11data = 10 | data11 = 10 | Variable cannot start with digit. | Python |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
if ($temp = 34) {{}} | if ($temp -eq 34) {{}} | Use -eq. | PowerShell |
SELECT * FROM products WHRE email=11; | SELECT * FROM products WHERE email=11; | Fix WHERE. | SQL |
values.forEach(function(b) {{ console.log(b); }}) | values.forEach((b) => {{ console.log(b); }}) | Arrow functions are cleaner. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
local index = 13 | local index = 13 | Correct. | Lua |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
for (int i=0; i<76; i++) {{}} | for (int i=0; i<76; i++) {{}} | Correct. | Java |
h1 {{ font-size:96px color:green; }} | h1 {{ font-size:96px; color:green; }} | Add semicolon. | CSS |
int[] data = new int[28];
data[28] = 5; | int[] data = new int[28];
if (28 < data.length) data[28] = 5; | Check bounds. | Java |
[x*x for x in list if x > 5] | [x*x for x in list if x > 5] | Correct list comprehension. | Python |
const a = 6; a = 36; | let a = 6; a = 36; | Cannot reassign const. | JavaScript |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
const b; | const b = 26; | Initialize const. | JavaScript |
echo data data | echo 'data data' | Quote to prevent splitting. | Shell |
if (bar = 6) {{}} | if (bar === 6) {{}} | Use === for equality. | JavaScript |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
'info' + 6 | 'info' + str(6) | Can't add int to string. | Python |
if b = 35: | if b == 35: | Use == for comparison. | Python |
values(83) | if length(values) >= 83, values(83), end | Check length. | MATLAB |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.