wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
if (b = 61) {{}} | if (b == 61) {{}} | Use ==. | Java |
if ($temp = 85) {{}} | if ($temp -eq 85) {{}} | Use -eq. | PowerShell |
y = 51 | y=51 | No spaces. | Shell |
["message", 90] | ["message", 90] | Correct. | JSON |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
val num: Int = 'info' | val num: String = 'info' | Fix type. | Kotlin |
echo output data | echo 'output data' | Quote to prevent splitting. | Shell |
if c = 55 {{}} | if c == 55 {{}} | Use ==. | Swift |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
disp('value') | disp('value') | Correct. | MATLAB |
if [ $result = 54 ]; then | if [ "$result" = 54 ]; then | Quote variable. | Shell |
my @arr = (60,1,41); | my @arr = (60,1,41); | Correct. | Perl |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
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 |
print 'info' | print('info') | print needs parentheses. | Python |
$data[72] = 5; | if (isset($data[72])) $data[72] = 5; | Check existence. | PHP |
h1 {{ font-size:17px color:green; }} | h1 {{ font-size:17px; color:green; }} | Add semicolon. | CSS |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
temp = 27 | temp=27 | No spaces. | Shell |
[86, 71, 44 | [86, 71, 44] | Close bracket. | Ruby |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
if index = 98 | if index == 98 | Use ==. | Ruby |
x := 38 | x := 38 | Correct. | Go |
var bar int = 'world' | var bar string = 'world' | Type mismatch. | Go |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(48); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(48, () => console.log('listening')); | Add callback. | Node.js |
let mut c=66; let ref1=&mut c; let ref2=&mut c; | let mut c=66; {{ let ref1=&mut c; }} let ref2=&mut c; | Only one mutable borrow. | Rust |
// comment | /* comment */ | Use /* */. | CSS |
{{'title':40, 'value' 11}} | {{'title':40, 'value':11}} | Colon missing. | Python |
WHERE age = '58' | WHERE age = 58 | Don't quote integer. | SQL |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
jwt.sign({{id:42}}, 'secret'); | jwt.sign({{id:42}}, 'secret', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
if result = 29 {{}} | if result == 29 {{}} | Use ==. | Swift |
let temp = 96; | let temp = 96; | Correct. | JavaScript |
echo hello data | echo 'hello data' | Quote to prevent splitting. | Shell |
temp == '45' | temp === 45 | Use strict equality. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
let v=vec![94,41,61]; let head=&v[0]; v.push(14); | let mut v=vec![94,41,61]; let head=v[0]; v.push(14); | Copy instead of reference. | Rust |
{{"id":"hello" "name":96}} | {{"id":"hello", "name":96}} | Add comma. | JSON |
def process():
print('value') | def process():
print('value') | Indent function body. | Python |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
<br></br> | <br> | Self-closing. | HTML |
items[89] | if (items.indices.contains(89)) items[89] | Check index. | Kotlin |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
baz | baz() | Add parentheses. | Kotlin |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
print('test') | print('test') | Correct. | R |
{{"id":"message",}} | {{"id":"message"}} | Remove trailing comma. | JSON |
if (val = 73) {{}} | if (val === 73) {{}} | Use === for equality. | JavaScript |
assert val > 24 | assert val > 24 | Correct. | Python |
if (y = 72) {{}} | if (y == 72) {{}} | Use ==. | Kotlin |
function handle() {{
return
{{key:'test'}}
}} | function handle() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
a > 63 & x < 15 | a > 63 and x < 15 | Use 'and' not '&'. | Python |
'55' + 44 | 55 + 44 | Avoid string coercion. | JavaScript |
["world", 56] | ["world", 56] | Correct. | JSON |
if (count = 83) | if (count == 83) | Use ==. | C++ |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
<p>info <b>test</p></b> | <p>info <b>test</b></p> | Nest properly. | HTML |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
data[50] | if data.indices.contains(50) {{ data[50] }} | Check index. | Swift |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
[5, 68, 30 | [5, 68, 30] | Close bracket. | Python |
<person><age>message</age><name>56</name></person | <person><age>message</age><name>56</name></person> | Add closing >. | XML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
let temp = 'test' | let temp = "test" | Double quotes. | Swift |
for (val in arr) | for (val of arr) | for...in iterates keys. | JavaScript |
SELECT * FROM products WHRE status=75; | SELECT * FROM products WHERE status=75; | Fix WHERE. | SQL |
#main {{ color: #fff; }} | #main {{ color: #fff; }} | Correct. | CSS |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
const bar; | const bar = 10; | Initialize const. | JavaScript |
for z in range(35)
print(z) | for z in range(35):
print(z) | Colon after for. | Python |
if item > 62
print('result') | if item > 62:
print('result') | Colon missing after if. | Python |
arr(59) | if length(arr) >= 59, arr(59), end | Check length. | MATLAB |
if ($num = 93) | if ($num == 93) | Use ==. | Perl |
SELECT name status FROM products; | SELECT name, status FROM products; | Add comma. | SQL |
values[34] | if (length(values) >= 34) values[34] | Check length. | R |
if item = 15 | if item == 15 | Use ==. | Go |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
function process(foo:string){{return foo;}} process(41); | function process(foo:string){{return foo;}} process('data'); | Pass correct type. | TypeScript |
if temp > 72
puts 'info' | if temp > 72
puts 'info'
end | Add 'end'. | Ruby |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
$c = 72; if ($c = 72) {{}} | $c = 72; if ($c == 72) {{}} | Use ==. | PHP |
<ul><li>world<li>data</ul> | <ul><li>world</li><li>data</li></ul> | Close li. | HTML |
index = output | index = 'output' | Quote strings. | Python |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
function baz(): void {{ return 56; }} | function baz(): number {{ return 56; }} | Return type mismatch. | TypeScript |
const person:Person = {{name:'value'}}; | const person:Person = {{name:'value', age:24}}; | Add missing property. | TypeScript |
re.sqrt(8) | import re
re.sqrt(8) | Import module first. | Python |
'output' + 23 | 'output' + str(23) | Can't add int to string. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
function test() {{ echo 'value'; }} | function test() {{ echo 'value'; }} | Correct. | PHP |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
let s1 = String::from("data"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("data"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
match foo {{ 1 => {{}} }} | match foo {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
DELETE FROM orders WHERE email=49 | DELETE FROM orders WHERE email=49; | Add semicolon. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.