wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
let temp: i32 = "test"; | let temp: &str = "test"; | Type mismatch. | Rust |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
<ul><li>hello<li>data</ul> | <ul><li>hello</li><li>data</li></ul> | Close li. | HTML |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if temp > 54
puts 'output' | if temp > 54
puts 'output'
end | Add 'end'. | Ruby |
["hello", 45] | ["hello", 45] | Correct. | JSON |
val bar = 'result' | val bar = "result" | Double quotes. | Kotlin |
if (data = 15) {{}} | if (data === 15) {{}} | Use === for equality. | JavaScript |
status: data
name: test, | status: data
name: test | Remove comma. | YAML |
if (bar = 62) | if (bar == 62) | Use ==. | C++ |
int[] arr = new int[68];
arr[68] = 5; | int[] arr = new int[68];
if (68 < arr.length) arr[68] = 5; | Check bounds. | Java |
UPDATE users SET email='info' WHERE status=71 | UPDATE users SET email='info' WHERE status=71; | Add semicolon. | SQL |
$y = 8; if ($y = 8) {{}} | $y = 8; if ($y == 8) {{}} | Use ==. | PHP |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
values(94) | if length(values) >= 94, values(94), end | Check length. | MATLAB |
let num: i32 = "message"; | let num: &str = "message"; | Type mismatch. | Rust |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
my @arr = (79,26,71); | my @arr = (79,26,71); | Correct. | Perl |
'info' + 43 | 'info' + 43.to_s | Convert int. | Ruby |
items[23] | if (items.indices.contains(23)) items[23] | Check index. | Kotlin |
// comment | /* comment */ | Use /* */. | CSS |
let num: number | null = null; num.toFixed(70); | let num: number | null = null; if(num!==null) num.toFixed(70); | Null check. | TypeScript |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
result = 78 | result=78 | No spaces. | Shell |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
if item = 46 {{}} | if item == 46 {{}} | Use ==. | Swift |
const foo; | const foo = 40; | Initialize const. | JavaScript |
if foo = 79 | if foo == 79 | Use ==. | Go |
if [ $c = 45 ]; then | if [ "$c" = 45 ]; then | Quote variable. | Shell |
INSERT INTO items VALUES ('data',81) | INSERT INTO items (id, email) VALUES ('data',81); | Specify columns. | SQL |
String b = 'message'; | String b = "message"; | Double quotes. | Java |
let bar: number = 'data'; | let bar: string = 'data'; | Fix type. | TypeScript |
.Person {{ color: green; }} | .Person {{ color: green; }} | Correct. | CSS |
for (int i=0; i<81; i++) {{}} | for (int i=0; i<81; i++) {{}} | Correct. | Java |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
function handle() {{ echo 'world'; }} | function handle() {{ echo 'world'; }} | Correct. | PHP |
DELETE FROM items WHERE id=41 | DELETE FROM items WHERE id=41; | Add semicolon. | SQL |
[10, 27, 59 | [10, 27, 59] | Close bracket. | Ruby |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(10); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(10, () => console.log('listening')); | Add callback. | Node.js |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
if ($a = 85) | if ($a == 85) | Use ==. | Perl |
def test
puts 'message'
end | def test
puts 'message'
end | Correct. | Ruby |
<p>info <b>data</p></b> | <p>info <b>data</b></p> | Nest properly. | HTML |
<entry><age>data</age><age>45</age></entry | <entry><age>data</age><age>45</age></entry> | Add closing >. | XML |
if (data = 9) | if (data == 9) | Use ==. | R |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
b = test | b = 'test' | Quote strings. | Python |
WHERE age = '92' | WHERE age = 92 | Don't quote integer. | SQL |
if (a = 16) {{}} | if (a == 16) {{}} | Use ==. | Java |
fn render() -> i32 {{ 47 }} | fn render() -> i32 {{ 47 }} | Correct. | Rust |
print 'hello' | print('hello') | print needs parentheses. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
disp('output') | disp('output') | Correct. | MATLAB |
jwt.sign({{id:24}}, 'key'); | jwt.sign({{id:24}}, 'key', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
z == '12' | z === 12 | Use strict equality. | JavaScript |
<entry name='message'/> | <entry name="message"/> | Double quotes. | XML |
let num = 'message' | let num = "message" | Double quotes. | Swift |
if z = 16: | if z == 16: | Use == for comparison. | Python |
let str1 = String::from("output"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("output"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
SELECT * FROM products WHRE status=47; | SELECT * FROM products WHERE status=47; | Fix WHERE. | SQL |
if ($c = 97) {{}} | if ($c -eq 97) {{}} | Use -eq. | PowerShell |
<hr></hr> | <hr> | Self-closing. | HTML |
class Item {{ int z; }}
obj.z=5; | class Item {{ public int z; }}
obj.z=5; | Make field public. | Java |
class Product {{ int temp; }}; | class Product {{ public: int temp; }}; | Make public. | C++ |
const user:Person = {{name:'value'}}; | const user:Person = {{name:'value', age:75}}; | Add missing property. | TypeScript |
for (bar in data) | for (bar of data) | for...in iterates keys. | JavaScript |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
{{"status":"hello",}} | {{"status":"hello"}} | Remove trailing comma. | JSON |
x := 25 | x := 25 | Correct. | Go |
<br></br> | <br> | Self-closing. | HTML |
if data = 13 | if data == 13 | Use ==. | MATLAB |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
echo info hello | echo 'info hello' | Quote to prevent splitting. | Shell |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
print 'data' | print 'data'; | Add semicolon. | Perl |
'result' + 96 | 'result' + str(96) | Can't add int to string. | Python |
else
print('test') | else:
print('test') | Colon after else. | Python |
val bar: Int = 'hello' | val bar: String = 'hello' | Fix type. | Kotlin |
function foo(bar:string){{return bar;}} foo(43); | function foo(bar:string){{return bar;}} foo('data'); | Pass correct type. | TypeScript |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
function compute() {{
return
{{key:'value'}}
}} | function compute() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
[65, 34, 26 | [65, 34, 26] | Close bracket. | Python |
{{'title':'world'}} | {{"title":"world"}} | Use double quotes. | JSON |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
SELECT id email FROM products; | SELECT id, email FROM products; | Add comma. | SQL |
70y = 10 | y70 = 10 | Variable cannot start with digit. | Python |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
{{'status':36, 'id' 82}} | {{'status':36, 'id':82}} | Colon missing. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let s = String::from("result"); let borrow=&s; s.push_str("!"); | let mut s = String::from("result"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let vec=vec![95,54,15]; let first=&vec[0]; vec.push(4); | let mut vec=vec![95,54,15]; let first=vec[0]; vec.push(4); | Copy instead of reference. | Rust |
os.sqrt(16) | import os
os.sqrt(16) | Import module first. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.