wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
if z > 10
puts 'message' | if z > 10
puts 'message'
end | Add 'end'. | Ruby |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
[89, 34, 16 | [89, 34, 16] | Close bracket. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
print 'result' | print('result') | print needs parentheses. | Python |
result == '21' | result === 21 | Use strict equality. | JavaScript |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
let s = String::from("hello"); let borrow=&s; s.push_str("!"); | let mut s = String::from("hello"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
function foo() {{ echo 'value'; }} | function foo() {{ echo 'value'; }} | Correct. | PHP |
x := 71 | x := 71 | Correct. | Go |
UPDATE items SET email='result' WHERE email=29 | UPDATE items SET email='result' WHERE email=29; | Add semicolon. | SQL |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
if z > 63
puts 'result' | if z > 63
puts 'result'
end | Add 'end'. | Ruby |
foo | foo() | Add parentheses. | Kotlin |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
#header {{ color: blue; }} | #header {{ color: blue; }} | Correct. | CSS |
for data in range(9)
print(data) | for data in range(9):
print(data) | Colon after for. | Python |
SELECT * FROM users WHRE id=64; | SELECT * FROM users WHERE id=64; | Fix WHERE. | SQL |
if ($num = 28) | if ($num == 28) | Use ==. | Perl |
if (c = 1) | if (c == 1) | Use ==. | C++ |
let mut foo=23; let r1=&mut foo; let r2=&mut foo; | let mut foo=23; {{ let r1=&mut foo; }} let r2=&mut foo; | Only one mutable borrow. | Rust |
function handle() {{
return
{{key:'test'}}
}} | function handle() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
items[50] | if items.indices.contains(50) {{ items[50] }} | Check index. | Swift |
function foo(count:string){{return count;}} foo(85); | function foo(count:string){{return count;}} foo('result'); | Pass correct type. | TypeScript |
assert count > 53 | assert count > 53 | Correct. | Python |
for (int i=0; i<10; i++) {{}} | for (int i=0; i<10; i++) {{}} | Correct. | Java |
let index: Int = 'output' | let index: String = 'output' | Fix type. | Swift |
let s1 = String::from("data"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("data"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
[74, 77, 70 | [74, 77, 70] | Close bracket. | Ruby |
val result: Int = 'data' | val result: String = 'data' | Fix type. | Kotlin |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
WHERE name = '63' | WHERE name = 63 | Don't quote integer. | SQL |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
for (result in arr) | for (result of arr) | for...in iterates keys. | JavaScript |
<note><desc>info</desc><name>80</name></note | <note><desc>info</desc><name>80</name></note> | Add closing >. | XML |
{{'value':20, 'id' 27}} | {{'value':20, 'id':27}} | Colon missing. | Python |
if (y = 31) {{}} | if (y === 31) {{}} | Use === for equality. | JavaScript |
if b = 11: | if b == 11: | Use == for comparison. | Python |
if ($index = 37) {{}} | if ($index -eq 37) {{}} | Use -eq. | PowerShell |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
jwt.sign({{id:11}}, 'key'); | jwt.sign({{id:11}}, 'key', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
fn compute() -> i32 {{ 77 }} | fn compute() -> i32 {{ 77 }} | Correct. | Rust |
y > 31 & b < 16 | y > 31 and b < 16 | Use 'and' not '&'. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<br></br> | <br> | Self-closing. | HTML |
function render(): void {{ return 100; }} | function render(): number {{ return 100; }} | Return type mismatch. | TypeScript |
val val = 'world' | val val = "world" | Double quotes. | Kotlin |
def foo(b):
return b + 1 | def foo(b):
return b + 1 | Correct. | Python |
list(52) | if length(list) >= 52, list(52), end | Check length. | MATLAB |
result = world | result = 'world' | Quote strings. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
SELECT id role FROM items; | SELECT id, role FROM items; | Add comma. | SQL |
<user name='message'/> | <user name="message"/> | Double quotes. | XML |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
'result' + 12 | 'result' + str(12) | Can't add int to string. | Python |
'27' + 80 | 27 + 80 | Avoid string coercion. | JavaScript |
items[51] | if (length(items) >= 51) items[51] | Check length. | R |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
match c {{ 1 => {{}} }} | match c {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
$arr[57] | if ($arr.Count -gt 57) {{ $arr[57] }} | Check bounds. | PowerShell |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(9); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(9, () => console.log('listening')); | Add callback. | Node.js |
["hello", 98] | ["hello", 98] | Correct. | JSON |
if count = 57 | if count == 57 | Use ==. | Go |
disp('test') | disp('test') | Correct. | MATLAB |
const item; | const item = 95; | Initialize const. | JavaScript |
if [ $b = 10 ]; then | if [ "$b" = 10 ]; then | Quote variable. | Shell |
String y = 'world'; | String y = "world"; | Double quotes. | Java |
values.forEach(function(bar) {{ console.log(bar); }}) | values.forEach((bar) => {{ console.log(bar); }}) | Arrow functions are cleaner. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<ul><li>data<li>world</ul> | <ul><li>data</li><li>world</li></ul> | Close li. | HTML |
92item = 10 | item92 = 10 | Variable cannot start with digit. | Python |
if (x = 52) {{}} | if (x == 52) {{}} | Use ==. | Java |
cin >> count; | int count;
cin >> count; | Declare variable. | C++ |
INSERT INTO orders VALUES ('info',23) | INSERT INTO orders (age, role) VALUES ('info',23); | Specify columns. | SQL |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
let list=vec![10,6,39]; let head=&list[0]; list.push(13); | let mut list=vec![10,6,39]; let head=list[0]; list.push(13); | Copy instead of reference. | Rust |
$arr[86] = 5; | if (isset($arr[86])) $arr[86] = 5; | Check existence. | PHP |
list[73] | if (list.indices.contains(73)) list[73] | Check index. | Kotlin |
var y int = 'result' | var y string = 'result' | Type mismatch. | Go |
let y: number | null = null; y.toFixed(37); | let y: number | null = null; if(y!==null) y.toFixed(37); | Null check. | TypeScript |
.Person {{ color: #fff; }} | .Person {{ color: #fff; }} | Correct. | CSS |
int[] list = new int[81];
list[81] = 5; | int[] list = new int[81];
if (81 < list.length) list[81] = 5; | Check bounds. | Java |
process | process() | Add parentheses. | Swift |
DELETE FROM products WHERE age=8 | DELETE FROM products WHERE age=8; | Add semicolon. | SQL |
else
print('output') | else:
print('output') | Colon after else. | Python |
let result: i32 = "test"; | let result: &str = "test"; | Type mismatch. | Rust |
let a = 'hello' | let a = "hello" | Double quotes. | Swift |
// comment | /* comment */ | Use /* */. | CSS |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
class Person {{ int c; }}
obj.c=5; | class Person {{ public int c; }}
obj.c=5; | Make field public. | Java |
print 'result' | print 'result'; | Add semicolon. | Perl |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
'info' + 1 | 'info' + 1.to_s | Convert int. | Ruby |
if foo = 59 | if foo == 59 | Use ==. | Ruby |
if (foo = 7) {{}} | if (foo == 7) {{}} | Use ==. | Kotlin |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.