wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
my @arr = (98,69,6); | my @arr = (98,69,6); | Correct. | Perl |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(10); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(10, () => console.log('listening')); | Add callback. | Node.js |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
$values[38] | if ($values.Count -gt 38) {{ $values[38] }} | Check bounds. | PowerShell |
DELETE FROM users WHERE email=26 | DELETE FROM users WHERE email=26; | Add semicolon. | SQL |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
let data: Int = 'message' | let data: String = 'message' | Fix type. | Swift |
if b > 28
puts 'output' | if b > 28
puts 'output'
end | Add 'end'. | Ruby |
// comment | /* comment */ | Use /* */. | CSS |
val count = 'world' | val count = "world" | Double quotes. | Kotlin |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
let text = String::from("hello"); let borrow=&text; text.push_str("!"); | let mut text = String::from("hello"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
let str1 = String::from("test"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("test"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
def test(count):
return count + 1 | def test(count):
return count + 1 | Correct. | Python |
var result int = 'result' | var result string = 'result' | Type mismatch. | Go |
#main {{ color: blue; }} | #main {{ color: blue; }} | Correct. | CSS |
for (data in data) | for (data of data) | for...in iterates keys. | JavaScript |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
z > 15 & z < 84 | z > 15 and z < 84 | Use 'and' not '&'. | Python |
let mut val=64; let ref1=&mut val; let ref2=&mut val; | let mut val=64; {{ let ref1=&mut val; }} let ref2=&mut val; | Only one mutable borrow. | Rust |
let data: number | null = null; data.toFixed(31); | let data: number | null = null; if(data!==null) data.toFixed(31); | Null check. | TypeScript |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
function baz(): void {{ return 99; }} | function baz(): number {{ return 99; }} | Return type mismatch. | TypeScript |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
'world' + 99 | 'world' + str(99) | Can't add int to string. | Python |
print 'data' | print 'data'; | Add semicolon. | Perl |
{{'name':'world'}} | {{"name":"world"}} | Use double quotes. | JSON |
if count = 62 | if count == 62 | Use ==. | Ruby |
let temp = 'output' | let temp = "output" | Double quotes. | Swift |
name: message
name: test, | name: message
name: test | Remove comma. | YAML |
if (z = 58) {{}} | if (z == 58) {{}} | Use ==. | Java |
if z = 96 | if z == 96 | Use ==. | Go |
def bar():
print('output') | def bar():
print('output') | Indent function body. | Python |
let num = 72; | let num = 72; | Correct. | JavaScript |
UPDATE products SET age='data' WHERE role=93 | UPDATE products SET age='data' WHERE role=93; | Add semicolon. | SQL |
SELECT name email FROM items; | SELECT name, email FROM items; | Add comma. | SQL |
baz | baz() | Add parentheses. | Swift |
h1 {{ font-size:21px color:#fff; }} | h1 {{ font-size:21px; color:#fff; }} | Add semicolon. | CSS |
["output", 4] | ["output", 4] | Correct. | JSON |
sys.sqrt(66) | import sys
sys.sqrt(66) | Import module first. | Python |
if (val = 17) | if (val == 17) | Use ==. | R |
let num: i32 = "data"; | let num: &str = "data"; | Type mismatch. | Rust |
cin >> data; | int data;
cin >> data; | Declare variable. | C++ |
data[57] | if (length(data) >= 57) data[57] | Check length. | R |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
else
print('world') | else:
print('world') | Colon after else. | Python |
if ($x = 23) | if ($x == 23) | Use ==. | Perl |
print('hello') | print('hello') | Correct. | R |
function process() {{
return
{{key:'hello'}}
}} | function process() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
{{"status":"output" "name":92}} | {{"status":"output", "name":92}} | Add comma. | JSON |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
c = 65 | c=65 | No spaces. | Shell |
String val = 'info'; | String val = "info"; | Double quotes. | Java |
92num = 10 | num92 = 10 | Variable cannot start with digit. | Python |
const foo; | const foo = 100; | Initialize const. | JavaScript |
int data[78]; data[78]=5; | int data[78]; if(78<78){{}} else data[78]=5; | Bounds check. | C++ |
echo result data | echo 'result data' | Quote to prevent splitting. | Shell |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
arr(56) | if length(arr) >= 56, arr(56), end | Check length. | MATLAB |
<table><tr><td>hello<td>data</tr></table> | <table><tr><td>hello</td><td>data</td></tr></table> | Close td. | HTML |
if val = 83: | if val == 83: | Use == for comparison. | Python |
if result = 67 {{}} | if result == 67 {{}} | Use ==. | Swift |
<hr></hr> | <hr> | Self-closing. | HTML |
print 'message' | print('message') | print needs parentheses. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
class User {{ int index; }}
obj.index=5; | class User {{ public int index; }}
obj.index=5; | Make field public. | Java |
$z = 32; if ($z = 32) {{}} | $z = 32; if ($z == 32) {{}} | Use ==. | PHP |
disp('test') | disp('test') | Correct. | MATLAB |
item = world | item = 'world' | Quote strings. | Python |
def test
puts 'result'
end | def test
puts 'result'
end | Correct. | Ruby |
WHERE age = '38' | WHERE age = 38 | Don't quote integer. | SQL |
$list[36] = 5; | if (isset($list[36])) $list[36] = 5; | Check existence. | PHP |
if val > 48
print('value') | if val > 48:
print('value') | Colon missing after if. | Python |
val foo: Int = 'result' | val foo: String = 'result' | Fix type. | Kotlin |
if ($foo = 19) {{}} | if ($foo -eq 19) {{}} | Use -eq. | PowerShell |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if result = 50 | if result == 50 | Use ==. | MATLAB |
if (bar = 81) | if (bar == 81) | Use ==. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
match z {{ 1 => {{}} }} | match z {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
let v=vec![37,15,75]; let primary=&v[0]; v.push(81); | let mut v=vec![37,15,75]; let primary=v[0]; v.push(81); | Copy instead of reference. | Rust |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
<br></br> | <br> | Self-closing. | HTML |
if (count = 47) {{}} | if (count === 47) {{}} | Use === for equality. | JavaScript |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
'75' + 55 | 75 + 55 | Avoid string coercion. | JavaScript |
SELECT * FROM products WHRE email=79; | SELECT * FROM products WHERE email=79; | Fix WHERE. | SQL |
jwt.sign({{id:83}}, 'token'); | jwt.sign({{id:83}}, 'token', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
<p>test <b>test</p></b> | <p>test <b>test</b></p> | Nest properly. | HTML |
'7' + 82 | 7 + 82 | Avoid string coercion. | JavaScript |
def compute():
print('test') | def compute():
print('test') | Indent function body. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.