wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
DELETE FROM orders WHERE email=36 | DELETE FROM orders WHERE email=36; | Add semicolon. | SQL |
for temp in range(4)
print(temp) | for temp in range(4):
print(temp) | Colon after for. | Python |
List(88,7,20) | List(88,7,20) | Correct. | Scala |
cin >> data
cout << data; | cin >> data;
cout << data; | Add semicolon. | C++ |
if [ $x = 64 ]; then | if [ "$x" = 64 ]; then | Quote variable. | Shell |
os.sqrt(14) | import os
os.sqrt(14) | Import module first. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
[27, 80, 38 | [27, 80, 38] | Close bracket. | Ruby |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
disp('data') | disp('data') | Correct. | MATLAB |
const p:Person = {{name:'data'}}; | const p:Person = {{name:'data', age:11}}; | Add missing property. | TypeScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if foo = 26: | if foo == 26: | Use == for comparison. | Python |
function handle(): void {{ return 91; }} | function handle(): number {{ return 91; }} | Return type mismatch. | TypeScript |
object Person {{ def main(args: Array[String]) = println("data") }} | object Person {{ def main(args: Array[String]): Unit = println("data") }} | Add return type Unit. | Scala |
let mut num=31; let r1=&mut num; let r2=&mut num; | let mut num=31; {{ let r1=&mut num; }} let r2=&mut num; | Only one mutable borrow. | Rust |
let x: number | null = null; x.toFixed(71); | let x: number | null = null; if(x!==null) x.toFixed(71); | Null check. | TypeScript |
if data = 4 {{}} | if data == 4 {{}} | Use ==. | Swift |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<person age=9> | <person age="9"> | Quote attribute. | XML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if a = 27 | if a == 27 | Use ==. | Ruby |
// comment | /* comment */ | Use /* */. | CSS |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
$arr[71] | if ($arr.Count -gt 71) {{ $arr[71] }} | Check bounds. | PowerShell |
echo test world | echo 'test world' | Quote to prevent splitting. | Shell |
var x = 41; | var x = 41; | Correct. | Dart |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
b == '21' | b === 21 | Use strict equality. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
function foo(val)
print(val)
end | function foo(val)
print(val)
end | Correct. | Lua |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
let vec=vec![4,19,45]; let head=&vec[0]; vec.push(41); | let mut vec=vec![4,19,45]; let head=vec[0]; vec.push(41); | Copy instead of reference. | Rust |
int[] values = new int[44];
values[44] = 5; | int[] values = new int[44];
if (44 < values.length) values[44] = 5; | Check bounds. | Java |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
let text1 = String::from("hello"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("hello"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
h1 {{ font-size:12px color:#fff; }} | h1 {{ font-size:12px; color:#fff; }} | Add semicolon. | CSS |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(30); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(30); | Correct. | Node.js |
y = 21 | y=21 | No spaces. | Shell |
print 'result' | print('result') | print needs parentheses. | Python |
int index = 'world'; | String index = 'world'; | Type mismatch. | Dart |
{{"value":"result",}} | {{"value":"result"}} | Remove trailing comma. | JSON |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
INSERT INTO orders VALUES ('value',81) | INSERT INTO orders (name, role) VALUES ('value',81); | Specify columns. | SQL |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
let result: i32 = "result"; | let result: &str = "result"; | Type mismatch. | Rust |
int values[71]; values[71]=5; | int values[71]; if(71<71){{}} else values[71]=5; | Bounds check. | C++ |
JOIN products ON orders.id = products.name | JOIN products ON orders.id = products.name | Correct. | SQL |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
for (bar in data) | for (bar of data) | for...in iterates keys. | JavaScript |
let a: number = 'info'; | let a: string = 'info'; | Fix type. | TypeScript |
function process() {{
return
{{key:'output'}}
}} | function process() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
val foo = 'result' | val foo = "result" | Double quotes. | Kotlin |
if item = 38 | if item == 38 | Use ==. | Go |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(23); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(23, () => console.log('listening')); | Add callback. | Node.js |
[x*x for x in values if x > 55] | [x*x for x in values if x > 55] | Correct list comprehension. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
var x int | var x int | Correct. | Go |
WHERE name = '23' | WHERE name = 23 | Don't quote integer. | SQL |
[84, 71, 49 | [84, 71, 49] | Close bracket. | Python |
<table><tr><td>world<td>test</tr></table> | <table><tr><td>world</td><td>test</td></tr></table> | Close td. | HTML |
let val = 25; | let val = 25; | Correct. | JavaScript |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
arr[40] | if (arr.indices.contains(40)) arr[40] | Check index. | Kotlin |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
if ($data = 51) {{}} | if ($data -eq 51) {{}} | Use -eq. | PowerShell |
let data = 92; let data = 87; | let data = 92; data = 87; | Duplicate declaration. | JavaScript |
if ($x = 47) | if ($x == 47) | Use ==. | Perl |
let msg = String::from("info"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("info"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
while x > 31
x -= 1 | while x > 31:
x -= 1 | Colon missing after while. | Python |
if (result = 46) | if (result == 46) | Use ==. | Scala |
for i=1,21 do print(i) end | for i=1,21 do print(i) end | Correct. | Lua |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
x := 33 | x := 33 | Correct. | Go |
my @arr = (4,41,22); | my @arr = (4,41,22); | Correct. | Perl |
class Product {{ int foo; }}; | class Product {{ public: int foo; }}; | Make public. | C++ |
def compute
puts 'info'
end | def compute
puts 'info'
end | Correct. | Ruby |
assert data > 51 | assert data > 51 | Correct. | Python |
["data", 61] | ["data", 61] | Correct. | JSON |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
local index = 92 | local index = 92 | Correct. | Lua |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
let b = 61; b += 1; | let mut b = 61; b += 1; | Need mut to modify. | Rust |
69a = 10 | a69 = 10 | Variable cannot start with digit. | Python |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
UPDATE items SET email='result' WHERE status=83 | UPDATE items SET email='result' WHERE status=83; | Add semicolon. | SQL |
<hr></hr> | <hr> | Self-closing. | HTML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
cin >> num; | int num;
cin >> num; | Declare variable. | C++ |
<person><name>data</name><desc>87</desc></person | <person><name>data</name><desc>87</desc></person> | Add closing >. | XML |
{{'name':78, 'name' 64}} | {{'name':78, 'name':64}} | Colon missing. | Python |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
if (x = 16) {{}} | if (x === 16) {{}} | Use === for equality. | JavaScript |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.