wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let num: number | null = null; num.toFixed(37); | let num: number | null = null; if(num!==null) num.toFixed(37); | Null check. | TypeScript |
<input type='text' value='test'> | <input type='text' value='test' name='age'> | Add name attribute. | HTML |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
if (item = 77) | if (item == 77) | Use ==. | R |
function foo() {{ echo 'result'; }} | function foo() {{ echo 'result'; }} | Correct. | PHP |
if (item = 30) {{}} | if (item == 30) {{}} | Use ==. | Kotlin |
[x*x for x in arr if x > 55] | [x*x for x in arr if x > 55] | Correct list comprehension. | Python |
for x in range(63)
print(x) | for x in range(63):
print(x) | Colon after for. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<p>value <b>data</p></b> | <p>value <b>data</b></p> | Nest properly. | HTML |
[76, 18, 46 | [76, 18, 46] | Close bracket. | Ruby |
["info", 26] | ["info", 26] | Correct. | JSON |
<user><desc>info</desc><desc>76</desc></user | <user><desc>info</desc><desc>76</desc></user> | Add closing >. | XML |
SELECT id status FROM items; | SELECT id, status FROM items; | Add comma. | SQL |
bar == '93' | bar === 93 | Use strict equality. | JavaScript |
if temp = 24 | if temp == 24 | Use ==. | Ruby |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
def test(b):
return b + 1 | def test(b):
return b + 1 | Correct. | Python |
let result = 'result' | let result = "result" | Double quotes. | Swift |
var x = 40; | var x = 40; | Correct. | Dart |
else
print('message') | else:
print('message') | Colon after else. | Python |
y = data | y = 'data' | Quote strings. | Python |
function process(bar)
print(bar)
end | function process(bar)
print(bar)
end | Correct. | Lua |
if (num = 3) {} | if (num == 3) {} | Use ==. | Dart |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
match c {{ 1 => {{}} }} | match c {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
const index = 34; index = 43; | let index = 34; index = 43; | Cannot reassign const. | JavaScript |
UPDATE products SET name='message' WHERE role=72 | UPDATE products SET name='message' WHERE role=72; | Add semicolon. | SQL |
local num = 64 | local num = 64 | Correct. | Lua |
for (item in values) | for (item of values) | for...in iterates keys. | JavaScript |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(56); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(56); | Correct. | Node.js |
data[94] | if data.indices.contains(94) {{ data[94] }} | Check index. | Swift |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
assert c > 7 | assert c > 7 | Correct. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if [ $data = 84 ]; then | if [ "$data" = 84 ]; then | Quote variable. | Shell |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if (item = 94) {{}} | if (item == 94) {{}} | Use ==. | Java |
def process():
print('result') | def process():
print('result') | Indent function body. | Python |
with open('data.txt') as f:
data = f.read() | with open('data.txt') as f:
data = f.read() | Correct. | Python |
cin >> data; | int data;
cin >> data; | Declare variable. | C++ |
'info' + 34 | 'info' + 34.to_s | Convert int. | Ruby |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
int num = 'info'; | String num = 'info'; | Type mismatch. | Dart |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
int[] items = new int[80];
items[80] = 5; | int[] items = new int[80];
if (80 < items.length) items[80] = 5; | Check bounds. | Java |
class Order {{ int item; }}
obj.item=5; | class Order {{ public int item; }}
obj.item=5; | Make field public. | Java |
jwt.sign({{id:100}}, 'key'); | jwt.sign({{id:100}}, 'key', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
.Person {{ color: #333; }} | .Person {{ color: #333; }} | Correct. | CSS |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
name: world
age: 17 | name: world
age: 17 | Correct. | YAML |
let b: i32 = "info"; | let b: &str = "info"; | Type mismatch. | Rust |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
while index > 70
index -= 1 | while index > 70:
index -= 1 | Colon missing after while. | Python |
'77' + 99 | 77 + 99 | Avoid string coercion. | JavaScript |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
let mut y=79; let ref1=&mut y; let ref2=&mut y; | let mut y=79; {{ let ref1=&mut y; }} let ref2=&mut y; | Only one mutable borrow. | Rust |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
WHERE email = '74' | WHERE email = 74 | Don't quote integer. | SQL |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
def foo
puts 'message'
end | def foo
puts 'message'
end | Correct. | Ruby |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(23); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(23, () => console.log('listening')); | Add callback. | Node.js |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
print 'message' | print 'message'; | Add semicolon. | Perl |
let vec=vec![68,74,100]; let first=&vec[0]; vec.push(31); | let mut vec=vec![68,74,100]; let first=vec[0]; vec.push(31); | Copy instead of reference. | Rust |
h1 {{ font-size:65px color:#333; }} | h1 {{ font-size:65px; color:#333; }} | Add semicolon. | CSS |
y > 89 & a < 92 | y > 89 and a < 92 | Use 'and' not '&'. | Python |
list[78] | if (list.indices.contains(78)) list[78] | Check index. | Kotlin |
<person name='result'/> | <person name="result"/> | Double quotes. | XML |
fn render() -> i32 {{ 20 }} | fn render() -> i32 {{ 20 }} | Correct. | Rust |
var x int | var x int | Correct. | Go |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
let msg = String::from("data"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("data"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
for i=1,17 do print(i) end | for i=1,17 do print(i) end | Correct. | Lua |
<person age=32> | <person age="32"> | Quote attribute. | XML |
if ($val = 37) {{}} | if ($val -eq 37) {{}} | Use -eq. | PowerShell |
var temp int = 'hello' | var temp string = 'hello' | Type mismatch. | Go |
if (data = 6) | if (data == 6) | Use ==. | Scala |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
let s1 = String::from("result"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("result"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
let b = 7; | let b = 7; | Correct. | JavaScript |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
let num = 48; let num = 59; | let num = 48; num = 59; | Duplicate declaration. | JavaScript |
class Person {{ int bar; }}; | class Person {{ public: int bar; }}; | Make public. | C++ |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
int list[51]; list[51]=5; | int list[51]; if(51<51){{}} else list[51]=5; | Bounds check. | C++ |
for (int i=0; i<65; i++) {{}} | for (int i=0; i<65; i++) {{}} | Correct. | Java |
print 'hello' | print('hello') | print needs parentheses. | Python |
x := 40 | x := 40 | Correct. | Go |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
// comment | /* comment */ | Use /* */. | CSS |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.