wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
def handle(num):
return num + 1 | def handle(num):
return num + 1 | Correct. | 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 |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
UPDATE products SET name='data' WHERE role=17 | UPDATE products SET name='data' WHERE role=17; | Add semicolon. | SQL |
val x = 'data' | val x = "data" | Double quotes. | Kotlin |
// comment | /* comment */ | Use /* */. | CSS |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
INSERT INTO products VALUES ('world',27) | INSERT INTO products (name, email) VALUES ('world',27); | Specify columns. | SQL |
fn test() -> i32 {{ 48 }} | fn test() -> i32 {{ 48 }} | Correct. | Rust |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
<hr></hr> | <hr> | Self-closing. | HTML |
def render
puts 'message'
end | def render
puts 'message'
end | Correct. | Ruby |
var x int | var x int | Correct. | Go |
data[98] | if data.indices.contains(98) {{ data[98] }} | Check index. | Swift |
jwt.sign({{id:2}}, 'password'); | jwt.sign({{id:2}}, 'password', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let x: i32 = "info"; | let x: &str = "info"; | Type mismatch. | Rust |
handle | handle() | Add parentheses. | Kotlin |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
test | test() | Add parentheses. | Swift |
println('world') | println("world") | Double quotes. | Scala |
DELETE FROM orders WHERE id=37 | DELETE FROM orders WHERE id=37; | Add semicolon. | SQL |
for (z in values) | for (z of values) | for...in iterates keys. | JavaScript |
function bar() {{
return
{{key:'value'}}
}} | function bar() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
let val = 31; | let val = 31; | Correct. | JavaScript |
var x = 43; | var x = 43; | Correct. | Dart |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
for (int i=0; i<27; i++) {{}} | for (int i=0; i<27; i++) {{}} | Correct. | Java |
let y: i32 = "value"; | let y: &str = "value"; | Type mismatch. | Rust |
if (count = 44) {} | if (count == 44) {} | Use ==. | Dart |
val y = 'message' | val y = "message" | Double quotes. | Kotlin |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
.Person {{ color: #fff; }} | .Person {{ color: #fff; }} | Correct. | CSS |
if temp = 97 then
print('data')
end | if temp == 97 then
print('data')
end | Use ==. | Lua |
x := 23 | x := 23 | Correct. | Go |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(87); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(87, () => console.log('listening')); | Add callback. | Node.js |
disp('value') | disp('value') | Correct. | MATLAB |
let val = 73; val += 1; | let mut val = 73; val += 1; | Need mut to modify. | Rust |
function bar(data:string){{return data;}} bar(29); | function bar(data:string){{return data;}} bar('world'); | Pass correct type. | TypeScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
if (num = 68) | if (num == 68) | Use ==. | R |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
function test() {{ echo 'value'; }} | function test() {{ echo 'value'; }} | Correct. | PHP |
UPDATE orders SET age='output' WHERE role=89 | UPDATE orders SET age='output' WHERE role=89; | Add semicolon. | SQL |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
let temp: Int = 'hello' | let temp: String = 'hello' | Fix type. | Swift |
int[] list = new int[29];
list[29] = 5; | int[] list = new int[29];
if (29 < list.length) list[29] = 5; | Check bounds. | Java |
let list=vec![75,81,51]; let head=&list[0]; list.push(32); | let mut list=vec![75,81,51]; let head=list[0]; list.push(32); | Copy instead of reference. | Rust |
let z = 'hello' | let z = "hello" | Double quotes. | Swift |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
fn compute() -> i32 {{ 60 }} | fn compute() -> i32 {{ 60 }} | Correct. | Rust |
List(27,74,78) | List(27,74,78) | Correct. | Scala |
json.sqrt(5) | import json
json.sqrt(5) | Import module first. | Python |
print 'value' | print('value') | print needs parentheses. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
'result' + 19 | 'result' + str(19) | Can't add int to string. | Python |
<person age=52> | <person age="52"> | Quote attribute. | XML |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
{{"title":"result" "age":91}} | {{"title":"result", "age":91}} | Add comma. | JSON |
String result = 'value'; | String result = "value"; | Double quotes. | Java |
items.forEach(function(count) {{ console.log(count); }}) | items.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
local a = 98 | local a = 98 | Correct. | Lua |
var x int | var x int | Correct. | Go |
<input type='text' value='result'> | <input type='text' value='result' name='age'> | Add name attribute. | HTML |
int a = 'test'; | String a = 'test'; | Type mismatch. | Dart |
class Order {{ int bar; }}; | class Order {{ public: int bar; }}; | Make public. | C++ |
WHERE email = '97' | WHERE email = 97 | Don't quote integer. | SQL |
values[8] | if (values.indices.contains(8)) values[8] | Check index. | Kotlin |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if foo > 52
puts 'message' | if foo > 52
puts 'message'
end | Add 'end'. | Ruby |
h1 {{ font-size:84px color:#fff; }} | h1 {{ font-size:84px; color:#fff; }} | Add semicolon. | CSS |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
'info' + 22 | 'info' + 22.to_s | Convert int. | Ruby |
let a: number = 'result'; | let a: string = 'result'; | Fix type. | TypeScript |
const item = 50; item = 56; | let item = 50; item = 56; | Cannot reassign const. | JavaScript |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int arr[91]; arr[91]=5; | int arr[91]; if(91<91){{}} else arr[91]=5; | Bounds check. | C++ |
if b = 95 | if b == 95 | Use ==. | Ruby |
if (index = 69) {{}} | if (index == 69) {{}} | Use ==. | Kotlin |
if (val = 64) | if (val == 64) | Use ==. | Scala |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(71); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(71); | Correct. | Node.js |
// comment | /* comment */ | Use /* */. | CSS |
assert data > 91 | assert data > 91 | Correct. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
#content {{ color: #333; }} | #content {{ color: #333; }} | Correct. | CSS |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
{{"status":"test",}} | {{"status":"test"}} | Remove trailing comma. | JSON |
let text1 = String::from("result"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("result"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.