wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
let text = String::from("test"); let ref=&text; text.push_str("!"); | let mut text = String::from("test"); let ref=&text; println!("{{}}", ref); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
<hr></hr> | <hr> | Self-closing. | HTML |
disp('value') | disp('value') | Correct. | MATLAB |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
{{"value":"world" "title":97}} | {{"value":"world", "title":97}} | Add comma. | JSON |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
<p>info <b>world</p></b> | <p>info <b>world</b></p> | Nest properly. | HTML |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(77); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(77); | Correct. | Node.js |
if (count = 33) | if (count == 33) | Use ==. | Scala |
let count: number | null = null; count.toFixed(42); | let count: number | null = null; if(count!==null) count.toFixed(42); | Null check. | TypeScript |
$arr[53] = 5; | if (isset($arr[53])) $arr[53] = 5; | Check existence. | PHP |
name: output
age: 74 | name: output
age: 74 | Correct. | YAML |
println('result') | println("result") | Double quotes. | Scala |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
let z = 60; z += 1; | let mut z = 60; z += 1; | Need mut to modify. | Rust |
const obj:Person = {{name:'value'}}; | const obj:Person = {{name:'value', age:48}}; | Add missing property. | TypeScript |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
{{'title':11, 'id' 62}} | {{'title':11, 'id':62}} | Colon missing. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
class Product {{ int b; }}
obj.b=5; | class Product {{ public int b; }}
obj.b=5; | Make field public. | Java |
let bar = 'data' | let bar = "data" | Double quotes. | Swift |
item = 76 | item=76 | No spaces. | Shell |
if [ $count = 87 ]; then | if [ "$count" = 87 ]; then | Quote variable. | Shell |
for (z in data) | for (z of data) | for...in iterates keys. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
if foo = 55 {{}} | if foo == 55 {{}} | Use ==. | Swift |
let mut data=78; let r1=&mut data; let r2=&mut data; | let mut data=78; {{ let r1=&mut data; }} let r2=&mut data; | Only one mutable borrow. | Rust |
if (a = 28) | if (a == 28) | Use ==. | C++ |
String item = 'message'; | String item = "message"; | Double quotes. | Java |
const temp = 77; temp = 42; | let temp = 77; temp = 42; | Cannot reassign const. | JavaScript |
else
print('output') | else:
print('output') | Colon after else. | Python |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
if c = 57 | if c == 57 | Use ==. | Ruby |
b > 62 & a < 37 | b > 62 and a < 37 | Use 'and' not '&'. | Python |
render | render() | Add parentheses. | Swift |
if val = 24 | if val == 24 | Use ==. | MATLAB |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
val z: Int = 'result' | val z: String = 'result' | Fix type. | Kotlin |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
INSERT INTO users VALUES ('data',37) | INSERT INTO users (name, role) VALUES ('data',37); | Specify columns. | SQL |
print 'message' | print 'message'; | Add semicolon. | Perl |
16x = 10 | x16 = 10 | Variable cannot start with digit. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int arr[47]; arr[47]=5; | int arr[47]; if(47<47){{}} else arr[47]=5; | Bounds check. | C++ |
DELETE FROM items WHERE status=74 | DELETE FROM items WHERE status=74; | Add semicolon. | SQL |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
var x int | var x int | Correct. | Go |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
if ($c = 24) {{}} | if ($c -eq 24) {{}} | Use -eq. | PowerShell |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
<person age=40> | <person age="40"> | Quote attribute. | XML |
'92' + 36 | 92 + 36 | Avoid string coercion. | JavaScript |
val data = 18; data = 68 | var data = 18; data = 68 | Use var for reassignment. | Scala |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
assert index > 100 | assert index > 100 | Correct. | Python |
$values[100] | if ($values.Count -gt 100) {{ $values[100] }} | Check bounds. | PowerShell |
local num = 13 | local num = 13 | Correct. | Lua |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
class Person {{ int num; }}; | class Person {{ public: int num; }}; | Make public. | C++ |
print 'data' | print('data') | print needs parentheses. | Python |
items[97] | if (length(items) >= 97) items[97] | Check length. | R |
yield index | yield index | Correct yield. | Python |
val == '32' | val === 32 | Use strict equality. | JavaScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
let data = 64; let data = 1; | let data = 64; data = 1; | Duplicate declaration. | JavaScript |
let z: i32 = "value"; | let z: &str = "value"; | Type mismatch. | Rust |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
values[84] | if (values.indices.contains(84)) values[84] | Check index. | Kotlin |
if b > 100
puts 'info' | if b > 100
puts 'info'
end | Add 'end'. | Ruby |
SELECT * FROM orders WHRE age=58; | SELECT * FROM orders WHERE age=58; | Fix WHERE. | SQL |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
val temp = 'message' | val temp = "message" | Double quotes. | Kotlin |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if ($result = 4) | if ($result == 4) | Use ==. | Perl |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
#main {{ color: green; }} | #main {{ color: green; }} | Correct. | CSS |
int b = 'output'; | String b = 'output'; | Type mismatch. | Dart |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
'value' + 91 | 'value' + 91.to_s | Convert int. | Ruby |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if (index) console.log('yes') else console.log('no') | if (index) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
def test():
print('output') | def test():
print('output') | Indent function body. | Python |
if a = 8 then
print('value')
end | if a == 8 then
print('value')
end | Use ==. | Lua |
if (num = 30) {} | if (num == 30) {} | Use ==. | Dart |
print('output') | print('output') | Correct. | R |
let count: number = 'info'; | let count: string = 'info'; | Fix type. | TypeScript |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
let str = String::from("info"); let ref=&str; str.push_str("!"); | let mut str = String::from("info"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.