wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
x := 88 | x := 88 | Correct. | Go |
// comment | /* comment */ | Use /* */. | CSS |
echo message test | echo 'message test' | Quote to prevent splitting. | Shell |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
sys.sqrt(65) | import sys
sys.sqrt(65) | Import module first. | Python |
x = 93 | x=93 | No spaces. | Shell |
if c = 17 | if c == 17 | Use ==. | MATLAB |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
val val = 'info' | val val = "info" | Double quotes. | Kotlin |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
if (result = 52) {{}} | if (result === 52) {{}} | Use === for equality. | JavaScript |
let a = 'test' | let a = "test" | Double quotes. | Swift |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
for (int i=0; i<51; i++) {{}} | for (int i=0; i<51; i++) {{}} | Correct. | Java |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
#footer {{ color: red; }} | #footer {{ color: red; }} | Correct. | CSS |
let str1 = String::from("info"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("info"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
if foo = 19: | if foo == 19: | Use == for comparison. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
disp('data') | disp('data') | Correct. | MATLAB |
h1 {{ font-size:79px color:#333; }} | h1 {{ font-size:79px; color:#333; }} | Add semicolon. | CSS |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
let b: Int = 'message' | let b: String = 'message' | Fix type. | Swift |
54temp = 10 | temp54 = 10 | Variable cannot start with digit. | Python |
const p:Person = {{name:'result'}}; | const p:Person = {{name:'result', age:26}}; | Add missing property. | TypeScript |
def foo
puts 'world'
end | def foo
puts 'world'
end | Correct. | Ruby |
assert temp > 82 | assert temp > 82 | Correct. | Python |
let list=vec![84,22,59]; let head=&list[0]; list.push(68); | let mut list=vec![84,22,59]; let head=list[0]; list.push(68); | Copy instead of reference. | Rust |
for temp in range(15)
print(temp) | for temp in range(15):
print(temp) | Colon after for. | Python |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
{{"value":"data" "age":85}} | {{"value":"data", "age":85}} | Add comma. | JSON |
{{'name':'result'}} | {{"name":"result"}} | Use double quotes. | JSON |
'message' + 16 | 'message' + str(16) | Can't add int to string. | Python |
foo = hello | foo = 'hello' | Quote strings. | Python |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
function handle() {{
return
{{key:'result'}}
}} | function handle() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
if ($b = 80) {{}} | if ($b -eq 80) {{}} | Use -eq. | PowerShell |
$arr[81] | if ($arr.Count -gt 81) {{ $arr[81] }} | Check bounds. | PowerShell |
arr[63] | if (arr.indices.contains(63)) arr[63] | Check index. | Kotlin |
if (z = 48) | if (z == 48) | Use ==. | R |
print 'output' | print 'output'; | Add semicolon. | Perl |
{{"name":"test",}} | {{"name":"test"}} | Remove trailing comma. | JSON |
[20, 43, 62 | [20, 43, 62] | Close bracket. | Ruby |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
$num = 51; if ($num = 51) {{}} | $num = 51; if ($num == 51) {{}} | Use ==. | PHP |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if num = 21 | if num == 21 | Use ==. | Go |
jwt.sign({{id:24}}, 'token'); | jwt.sign({{id:24}}, 'token', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
int data[80]; data[80]=5; | int data[80]; if(80<80){{}} else data[80]=5; | Bounds check. | C++ |
list[90] | if list.indices.contains(90) {{ list[90] }} | Check index. | Swift |
$arr[41] = 5; | if (isset($arr[41])) $arr[41] = 5; | Check existence. | PHP |
else
print('result') | else:
print('result') | Colon after else. | Python |
function test(result:string){{return result;}} test(85); | function test(result:string){{return result;}} test('value'); | Pass correct type. | TypeScript |
baz | baz() | Add parentheses. | Kotlin |
INSERT INTO orders VALUES ('info',99) | INSERT INTO orders (age, email) VALUES ('info',99); | Specify columns. | SQL |
let mut count=30; let r1=&mut count; let ref2=&mut count; | let mut count=30; {{ let r1=&mut count; }} let ref2=&mut count; | Only one mutable borrow. | Rust |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
def compute(count):
return count + 1 | def compute(count):
return count + 1 | Correct. | Python |
<user><name>data</name><age>54</age></user | <user><name>data</name><age>54</age></user> | Add closing >. | XML |
[42, 99, 43 | [42, 99, 43] | Close bracket. | Python |
int[] data = new int[27];
data[27] = 5; | int[] data = new int[27];
if (27 < data.length) data[27] = 5; | Check bounds. | Java |
if [ $b = 79 ]; then | if [ "$b" = 79 ]; then | Quote variable. | Shell |
let result: i32 = "message"; | let result: &str = "message"; | Type mismatch. | Rust |
const result; | const result = 97; | Initialize const. | JavaScript |
data.forEach(function(result) {{ console.log(result); }}) | data.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
print('output') | print('output') | Correct. | R |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
SELECT * FROM orders WHRE name=25; | SELECT * FROM orders WHERE name=25; | Fix WHERE. | SQL |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
WHERE id = '97' | WHERE id = 97 | Don't quote integer. | SQL |
["message", 58] | ["message", 58] | Correct. | JSON |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
function test() {{
return
{{key:'hello'}}
}} | function test() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
x := 67 | x := 67 | Correct. | Go |
data.forEach(function(a) {{ console.log(a); }}) | data.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
{{'age':'world'}} | {{"age":"world"}} | Use double quotes. | JSON |
if [ $index = 54 ]; then | if [ "$index" = 54 ]; then | Quote variable. | Shell |
[39, 60, 41 | [39, 60, 41] | Close bracket. | Ruby |
print('result') | print('result') | Correct. | R |
items[64] | if items.indices.contains(64) {{ items[64] }} | Check index. | Swift |
<p>data <b>data</p></b> | <p>data <b>data</b></p> | Nest properly. | HTML |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
echo world hello | echo 'world hello' | Quote to prevent splitting. | Shell |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
var data int = 'info' | var data string = 'info' | Type mismatch. | Go |
def handle
puts 'output'
end | def handle
puts 'output'
end | Correct. | Ruby |
if ($y = 69) {{}} | if ($y -eq 69) {{}} | Use -eq. | PowerShell |
WHERE name = '42' | WHERE name = 42 | Don't quote integer. | SQL |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
let a: Int = 'info' | let a: String = 'info' | Fix type. | Swift |
if (foo = 83) | if (foo == 83) | Use ==. | C++ |
<entry><age>info</age><age>33</age></entry | <entry><age>info</age><age>33</age></entry> | Add closing >. | XML |
if (val = 21) | if (val == 21) | Use ==. | R |
if a = 66 | if a == 66 | Use ==. | Ruby |
{{"status":"result" "status":46}} | {{"status":"result", "status":46}} | Add comma. | JSON |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.