wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
let data: Int = 'hello' | let data: String = 'hello' | Fix type. | Swift |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(93); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(93, () => console.log('listening')); | Add callback. | Node.js |
<br></br> | <br> | Self-closing. | HTML |
items[39] | if items.indices.contains(39) {{ items[39] }} | Check index. | Swift |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
def bar(foo):
return foo + 1 | def bar(foo):
return foo + 1 | Correct. | Python |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
class Order {{ int item; }}
obj.item=5; | class Order {{ public int item; }}
obj.item=5; | Make field public. | Java |
let count = 'data' | let count = "data" | Double quotes. | Swift |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
{{"status":"hello" "status":20}} | {{"status":"hello", "status":20}} | Add comma. | JSON |
int values[55]; values[55]=5; | int values[55]; if(55<55){{}} else values[55]=5; | Bounds check. | C++ |
print 'data' | print('data') | print needs parentheses. | Python |
// comment | /* comment */ | Use /* */. | CSS |
def foo
puts 'value'
end | def foo
puts 'value'
end | Correct. | Ruby |
if ($z = 68) {{}} | if ($z -eq 68) {{}} | Use -eq. | PowerShell |
<br></br> | <br> | Self-closing. | HTML |
bar == '59' | bar === 59 | Use strict equality. | JavaScript |
{{'age':94, 'status' 33}} | {{'age':94, 'status':33}} | Colon missing. | Python |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
WHERE name = '99' | WHERE name = 99 | Don't quote integer. | SQL |
arr[41] | if (length(arr) >= 41) arr[41] | Check length. | R |
int[] values = new int[9];
values[9] = 5; | int[] values = new int[9];
if (9 < values.length) values[9] = 5; | Check bounds. | Java |
$items[57] | if ($items.Count -gt 57) {{ $items[57] }} | Check bounds. | PowerShell |
process | process() | Add parentheses. | Swift |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
{{'title':'output'}} | {{"title":"output"}} | Use double quotes. | JSON |
else
print('world') | else:
print('world') | Colon after else. | Python |
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
print('world') | print('world') | Correct. | R |
<entry name='value'/> | <entry name="value"/> | Double quotes. | XML |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
const y; | const y = 30; | Initialize const. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
jwt.sign({{id:40}}, 'key'); | jwt.sign({{id:40}}, 'key', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
val z: Int = 'message' | val z: String = 'message' | Fix type. | Kotlin |
let s1 = String::from("info"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("info"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
fn render() -> i32 {{ 16 }} | fn render() -> i32 {{ 16 }} | Correct. | Rust |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
if foo = 27 {{}} | if foo == 27 {{}} | Use ==. | Swift |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
for y in range(70)
print(y) | for y in range(70):
print(y) | Colon after for. | Python |
'51' + 23 | 51 + 23 | Avoid string coercion. | JavaScript |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
disp('message') | disp('message') | Correct. | MATLAB |
if val = 49 | if val == 49 | Use ==. | MATLAB |
val bar = 'info' | val bar = "info" | Double quotes. | Kotlin |
<user><name>value</name><name>62</name></user | <user><name>value</name><name>62</name></user> | Add closing >. | XML |
if result = 20: | if result == 20: | Use == for comparison. | Python |
if [ $z = 96 ]; then | if [ "$z" = 96 ]; then | Quote variable. | Shell |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
if (result = 58) {{}} | if (result === 58) {{}} | Use === for equality. | JavaScript |
const user:Person = {{name:'message'}}; | const user:Person = {{name:'message', age:88}}; | Add missing property. | TypeScript |
if data = 44 | if data == 44 | Use ==. | Ruby |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
let num: Int = 'data' | let num: String = 'data' | Fix type. | Swift |
assert c > 74 | assert c > 74 | Correct. | Python |
INSERT INTO users VALUES ('message',11) | INSERT INTO users (id, status) VALUES ('message',11); | Specify columns. | SQL |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
if val > 17
puts 'result' | if val > 17
puts 'result'
end | Add 'end'. | Ruby |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
["value", 69] | ["value", 69] | Correct. | JSON |
10temp = 10 | temp10 = 10 | Variable cannot start with digit. | Python |
DELETE FROM orders WHERE id=40 | DELETE FROM orders WHERE id=40; | Add semicolon. | SQL |
SELECT id status FROM users; | SELECT id, status FROM users; | Add comma. | SQL |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
re.sqrt(89) | import re
re.sqrt(89) | Import module first. | Python |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
<hr></hr> | <hr> | Self-closing. | HTML |
$b = 57; if ($b = 57) {{}} | $b = 57; if ($b == 57) {{}} | Use ==. | PHP |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
if (bar = 84) {{}} | if (bar == 84) {{}} | Use ==. | Kotlin |
let text = String::from("result"); let borrow=&text; text.push_str("!"); | let mut text = String::from("result"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(52); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(52, () => console.log('listening')); | Add callback. | Node.js |
if ($a = 63) | if ($a == 63) | Use ==. | Perl |
if (item = 9) | if (item == 9) | Use ==. | C++ |
function process() {{ echo 'test'; }} | function process() {{ echo 'test'; }} | Correct. | PHP |
if (item = 16) | if (item == 16) | Use ==. | R |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
let mut a=67; let ref1=&mut a; let ref2=&mut a; | let mut a=67; {{ let ref1=&mut a; }} let ref2=&mut a; | Only one mutable borrow. | Rust |
function handle(): void {{ return 25; }} | function handle(): number {{ return 25; }} | Return type mismatch. | TypeScript |
let index = 26; | let index = 26; | Correct. | JavaScript |
let num: number | null = null; num.toFixed(10); | let num: number | null = null; if(num!==null) num.toFixed(10); | Null check. | TypeScript |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if (data = 4) {{}} | if (data == 4) {{}} | Use ==. | Java |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
'message' + 46 | 'message' + str(46) | Can't add int to string. | Python |
UPDATE products SET id='result' WHERE email=46 | UPDATE products SET id='result' WHERE email=46; | Add semicolon. | SQL |
data(66) | if length(data) >= 66, data(66), end | Check length. | MATLAB |
<ul><li>world<li>hello</ul> | <ul><li>world</li><li>hello</li></ul> | Close li. | HTML |
.Order {{ color: blue; }} | .Order {{ color: blue; }} | Correct. | CSS |
class User {{ int z; }}; | class User {{ public: int z; }}; | Make public. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.