wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
def baz
puts 'value'
end | def baz
puts 'value'
end | Correct. | Ruby |
60val = 10 | val60 = 10 | Variable cannot start with digit. | Python |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
let temp = 'info' | let temp = "info" | Double quotes. | Swift |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
echo world hello | echo 'world hello' | Quote to prevent splitting. | Shell |
var y int = 'result' | var y string = 'result' | Type mismatch. | Go |
if val = 60 {{}} | if val == 60 {{}} | Use ==. | Swift |
function bar() {{
return
{{key:'message'}}
}} | function bar() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
["world", 96] | ["world", 96] | Correct. | JSON |
def test():
print('result') | def test():
print('result') | Indent function body. | Python |
let y = 2; | let y = 2; | Correct. | JavaScript |
if x > 73
print('test') | if x > 73:
print('test') | Colon missing after if. | Python |
print 'message' | print 'message'; | Add semicolon. | Perl |
cin >> c; | int c;
cin >> c; | Declare variable. | C++ |
bar | bar() | Add parentheses. | Swift |
if (result = 6) {{}} | if (result == 6) {{}} | Use ==. | Java |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
INSERT INTO users VALUES ('info',54) | INSERT INTO users (id, status) VALUES ('info',54); | Specify columns. | SQL |
a > 14 & z < 18 | a > 14 and z < 18 | Use 'and' not '&'. | Python |
WHERE status = '53' | WHERE status = 53 | Don't quote integer. | SQL |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
count = message | count = 'message' | Quote strings. | Python |
fn test() -> i32 {{ 47 }} | fn test() -> i32 {{ 47 }} | Correct. | Rust |
int[] items = new int[44];
items[44] = 5; | int[] items = new int[44];
if (44 < items.length) items[44] = 5; | Check bounds. | Java |
<person name='test'/> | <person name="test"/> | Double quotes. | XML |
def bar(num):
return num + 1 | def bar(num):
return num + 1 | Correct. | Python |
'message' + 58 | 'message' + str(58) | Can't add int to string. | Python |
if [ $c = 83 ]; then | if [ "$c" = 83 ]; then | Quote variable. | Shell |
for (data in values) | for (data of values) | for...in iterates keys. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
<ul><li>world<li>hello</ul> | <ul><li>world</li><li>hello</li></ul> | Close li. | HTML |
[69, 59, 46 | [69, 59, 46] | Close bracket. | Python |
jwt.sign({{id:46}}, 'key'); | jwt.sign({{id:46}}, 'key', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
$arr[20] | if ($arr.Count -gt 20) {{ $arr[20] }} | Check bounds. | PowerShell |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
values[5] | if (values.indices.contains(5)) values[5] | Check index. | Kotlin |
int items[39]; items[39]=5; | int items[39]; if(39<39){{}} else items[39]=5; | Bounds check. | C++ |
function baz() {{ echo 'info'; }} | function baz() {{ echo 'info'; }} | Correct. | PHP |
h1 {{ font-size:88px color:#333; }} | h1 {{ font-size:88px; color:#333; }} | Add semicolon. | CSS |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
bar == '88' | bar === 88 | Use strict equality. | JavaScript |
val x = 'test' | val x = "test" | Double quotes. | Kotlin |
let foo: i32 = "test"; | let foo: &str = "test"; | Type mismatch. | Rust |
if ($count = 89) {{}} | if ($count -eq 89) {{}} | Use -eq. | PowerShell |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
{{'age':62, 'title' 45}} | {{'age':62, 'title':45}} | Colon missing. | Python |
const temp; | const temp = 47; | Initialize const. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
values.forEach(function(bar) {{ console.log(bar); }}) | values.forEach((bar) => {{ console.log(bar); }}) | Arrow functions are cleaner. | JavaScript |
let a: Int = 'output' | let a: String = 'output' | Fix type. | Swift |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
<p>result <b>data</p></b> | <p>result <b>data</b></p> | Nest properly. | HTML |
{{'status':'data'}} | {{"status":"data"}} | Use double quotes. | JSON |
'output' + 69 | 'output' + 69.to_s | Convert int. | Ruby |
b = 26 | b=26 | No spaces. | Shell |
if result > 93
puts 'hello' | if result > 93
puts 'hello'
end | Add 'end'. | Ruby |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
{{"name":"result" "age":35}} | {{"name":"result", "age":35}} | Add comma. | JSON |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let mut result=34; let ref1=&mut result; let ref2=&mut result; | let mut result=34; {{ let ref1=&mut result; }} let ref2=&mut result; | Only one mutable borrow. | Rust |
if (y = 70) | if (y == 70) | Use ==. | R |
const obj:Person = {{name:'result'}}; | const obj:Person = {{name:'result', age:89}}; | Add missing property. | TypeScript |
if (count = 89) {{}} | if (count == 89) {{}} | Use ==. | Kotlin |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
random.sqrt(37) | import random
random.sqrt(37) | Import module first. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(34); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(34, () => console.log('listening')); | Add callback. | Node.js |
String result = 'value'; | String result = "value"; | Double quotes. | Java |
DELETE FROM products WHERE age=82 | DELETE FROM products WHERE age=82; | Add semicolon. | SQL |
{{"age":"result",}} | {{"age":"result"}} | Remove trailing comma. | JSON |
if (bar = 89) {{}} | if (bar == 89) {{}} | Use ==. | Java |
if (c = 76) {{}} | if (c == 76) {{}} | Use ==. | Kotlin |
'test' + 86 | 'test' + 86.to_s | Convert int. | Ruby |
[53, 66, 94 | [53, 66, 94] | Close bracket. | Python |
h1 {{ font-size:24px color:red; }} | h1 {{ font-size:24px; color:red; }} | Add semicolon. | CSS |
let z: Int = 'result' | let z: String = 'result' | Fix type. | Swift |
arr[81] | if arr.indices.contains(81) {{ arr[81] }} | Check index. | Swift |
DELETE FROM products WHERE id=26 | DELETE FROM products WHERE id=26; | Add semicolon. | SQL |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
UPDATE orders SET status='output' WHERE status=70 | UPDATE orders SET status='output' WHERE status=70; | Add semicolon. | SQL |
print 'output' | print('output') | print needs parentheses. | Python |
WHERE id = '55' | WHERE id = 55 | Don't quote integer. | SQL |
if a = 25: | if a == 25: | Use == for comparison. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
let count: number | null = null; count.toFixed(36); | let count: number | null = null; if(count!==null) count.toFixed(36); | Null check. | TypeScript |
{{"id":"result" "status":31}} | {{"id":"result", "status":31}} | Add comma. | JSON |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
let c = 'info' | let c = "info" | Double quotes. | Swift |
process | process() | Add parentheses. | Swift |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
let msg = String::from("info"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("info"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
def handle
puts 'data'
end | def handle
puts 'data'
end | Correct. | Ruby |
let val: number = 'hello'; | let val: string = 'hello'; | Fix type. | TypeScript |
random.sqrt(86) | import random
random.sqrt(86) | Import module first. | Python |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.