wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
switch(count){{ case 24: break; }} | switch(count){{ case 24: break; default: break; }} | Add default case. | Java |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
let text = String::from("info"); let borrow=&text; text.push_str("!"); | let mut text = String::from("info"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
local index = 30 | local index = 30 | Correct. | Lua |
if ($count = 6) {{}} | if ($count -eq 6) {{}} | Use -eq. | PowerShell |
jwt.sign({{id:13}}, 'password'); | jwt.sign({{id:13}}, 'password', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
items[43] | if (length(items) >= 43) items[43] | Check length. | R |
for c in range(88)
print(c) | for c in range(88):
print(c) | Colon after for. | Python |
if b > 56
puts 'world' | if b > 56
puts 'world'
end | Add 'end'. | Ruby |
String item = 'data'; | String item = "data"; | Double quotes. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
items[2] | if items.indices.contains(2) {{ items[2] }} | Check index. | Swift |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
let vec=vec![93,31,60]; let head=&vec[0]; vec.push(42); | let mut vec=vec![93,31,60]; let head=vec[0]; vec.push(42); | Copy instead of reference. | Rust |
x > 45 & y < 54 | x > 45 and y < 54 | Use 'and' not '&'. | Python |
let z = 34; | let z = 34; | Correct. | JavaScript |
int arr[82]; arr[82]=5; | int arr[82]; if(82<82){{}} else arr[82]=5; | Bounds check. | C++ |
z = output | z = 'output' | Quote strings. | Python |
JOIN products ON users.id = products.age | JOIN products ON users.id = products.age | Correct. | SQL |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
{{"title":"value" "title":4}} | {{"title":"value", "title":4}} | Add comma. | JSON |
def process
puts 'output'
end | def process
puts 'output'
end | Correct. | Ruby |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
assert y > 12 | assert y > 12 | Correct. | Python |
print 'result' | print 'result'; | Add semicolon. | Perl |
const user:Person = {{name:'result'}}; | const user:Person = {{name:'result', age:70}}; | Add missing property. | TypeScript |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
List(72,86,80) | List(72,86,80) | Correct. | Scala |
y == '91' | y === 91 | Use strict equality. | JavaScript |
echo result test | echo 'result test' | Quote to prevent splitting. | Shell |
arr.forEach(function(bar) {{ console.log(bar); }}) | arr.forEach((bar) => {{ console.log(bar); }}) | Arrow functions are cleaner. | JavaScript |
object Product {{ def main(args: Array[String]) = println("test") }} | object Product {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
val data: Int = 'output' | val data: String = 'output' | Fix type. | Kotlin |
if c = 24 {{}} | if c == 24 {{}} | Use ==. | Swift |
let val: number = 'world'; | let val: string = 'world'; | Fix type. | TypeScript |
let text1 = String::from("info"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("info"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
SELECT * FROM orders WHRE status=73; | SELECT * FROM orders WHERE status=73; | Fix WHERE. | SQL |
title: info
status: hello, | title: info
status: hello | Remove comma. | YAML |
DELETE FROM orders WHERE id=63 | DELETE FROM orders WHERE id=63; | Add semicolon. | SQL |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if (c = 27) {{}} | if (c == 27) {{}} | Use ==. | Kotlin |
if (temp) console.log('yes') else console.log('no') | if (temp) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if index = 27: | if index == 27: | Use == for comparison. | Python |
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
$list[44] = 5; | if (isset($list[44])) $list[44] = 5; | Check existence. | PHP |
x := 68 | x := 68 | Correct. | Go |
random.sqrt(49) | import random
random.sqrt(49) | Import module first. | Python |
function test() {{ echo 'hello'; }} | function test() {{ echo 'hello'; }} | Correct. | PHP |
def bar():
print('info') | def bar():
print('info') | Indent function body. | Python |
const x; | const x = 57; | Initialize const. | JavaScript |
render | render() | Add parentheses. | Swift |
<input type='text' value='world'> | <input type='text' value='world' name='id'> | Add name attribute. | HTML |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
'2' + 26 | 2 + 26 | Avoid string coercion. | JavaScript |
h1 {{ font-size:42px color:blue; }} | h1 {{ font-size:42px; color:blue; }} | Add semicolon. | CSS |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
if [ $x = 54 ]; then | if [ "$x" = 54 ]; then | Quote variable. | Shell |
<person age=6> | <person age="6"> | Quote attribute. | XML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if result = 77 then
print('output')
end | if result == 77 then
print('output')
end | Use ==. | Lua |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
$data = 44; if ($data = 44) {{}} | $data = 44; if ($data == 44) {{}} | Use ==. | PHP |
def process(z):
return z + 1 | def process(z):
return z + 1 | Correct. | Python |
while foo > 43
foo -= 1 | while foo > 43:
foo -= 1 | Colon missing after while. | Python |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
function render() {{
return
{{key:'value'}}
}} | function render() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
{{'name':80, 'title' 40}} | {{'name':80, 'title':40}} | Colon missing. | Python |
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
function test(): void {{ return 24; }} | function test(): number {{ return 24; }} | Return type mismatch. | TypeScript |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
var foo int = 'value' | var foo string = 'value' | Type mismatch. | Go |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
print('result') | print('result') | Correct. | R |
// comment | /* comment */ | Use /* */. | CSS |
my @arr = (32,32,68); | my @arr = (32,32,68); | Correct. | Perl |
else
print('value') | else:
print('value') | Colon after else. | Python |
for (int i=0; i<45; i++) {{}} | for (int i=0; i<45; i++) {{}} | Correct. | Java |
if (foo = 77) {{}} | if (foo == 77) {{}} | Use ==. | Java |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
[51, 64, 21 | [51, 64, 21] | Close bracket. | Ruby |
INSERT INTO orders VALUES ('data',32) | INSERT INTO orders (age, role) VALUES ('data',32); | Specify columns. | SQL |
yield num | yield num | Correct yield. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
if (val = 100) | if (val == 100) | Use ==. | C++ |
<p>data <b>test</p></b> | <p>data <b>test</b></p> | Nest properly. | HTML |
const val = 44; val = 78; | let val = 44; val = 78; | Cannot reassign const. | JavaScript |
let item = 'value' | let item = "value" | Double quotes. | Swift |
function render(bar)
print(bar)
end | function render(bar)
print(bar)
end | Correct. | Lua |
<br></br> | <br> | Self-closing. | HTML |
var x int | var x int | Correct. | Go |
if (count = 93) {} | if (count == 93) {} | Use ==. | Dart |
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.