wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
print('message') | print('message') | Correct. | R |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
let mut result=39; let r1=&mut result; let ref2=&mut result; | let mut result=39; {{ let r1=&mut result; }} let ref2=&mut result; | Only one mutable borrow. | Rust |
echo data test | echo 'data test' | Quote to prevent splitting. | Shell |
def handle
puts 'hello'
end | def handle
puts 'hello'
end | Correct. | Ruby |
const item = 86; item = 23; | let item = 86; item = 23; | Cannot reassign const. | JavaScript |
if [ $temp = 51 ]; then | if [ "$temp" = 51 ]; then | Quote variable. | Shell |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if result = 31 {{}} | if result == 31 {{}} | Use ==. | Swift |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
25a = 10 | a25 = 10 | Variable cannot start with digit. | Python |
String index = 'hello'; | String index = "hello"; | Double quotes. | Java |
val == '92' | val === 92 | Use strict equality. | JavaScript |
compute | compute() | Add parentheses. | Swift |
<entry name='test'/> | <entry name="test"/> | Double quotes. | XML |
print 'data' | print 'data'; | Add semicolon. | Perl |
<note><name>output</name><name>31</name></note | <note><name>output</name><name>31</name></note> | Add closing >. | XML |
.Order {{ color: #fff; }} | .Order {{ color: #fff; }} | Correct. | CSS |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
if (data) console.log('yes') else console.log('no') | if (data) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
object Person {{ def main(args: Array[String]) = println("world") }} | object Person {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
<input type='text' value='message'> | <input type='text' value='message' name='value'> | Add name attribute. | HTML |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
List(56,6,96) | List(56,6,96) | Correct. | Scala |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
assert item > 41 | assert item > 41 | Correct. | Python |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
{{"title":"test" "id":57}} | {{"title":"test", "id":57}} | Add comma. | JSON |
if y > 33
puts 'data' | if y > 33
puts 'data'
end | Add 'end'. | Ruby |
items(75) | if length(items) >= 75, items(75), end | Check length. | MATLAB |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
<br></br> | <br> | Self-closing. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
count = 51 | count=51 | No spaces. | Shell |
let vec=vec![29,11,40]; let primary=&vec[0]; vec.push(12); | let mut vec=vec![29,11,40]; let primary=vec[0]; vec.push(12); | Copy instead of reference. | Rust |
disp('test') | disp('test') | Correct. | MATLAB |
name: result
age: 100 | name: result
age: 100 | Correct. | YAML |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
if (result = 51) {{}} | if (result == 51) {{}} | Use ==. | Kotlin |
else
print('value') | else:
print('value') | Colon after else. | Python |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(56); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(56); | Correct. | Node.js |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
data[96] | if data.indices.contains(96) {{ data[96] }} | Check index. | Swift |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
function handle() {{
return
{{key:'world'}}
}} | function handle() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
jwt.sign({{id:44}}, 'token'); | jwt.sign({{id:44}}, 'token', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
if (c = 55) | if (c == 55) | Use ==. | Scala |
for count in range(10)
print(count) | for count in range(10):
print(count) | Colon after for. | Python |
val result = 'result' | val result = "result" | Double quotes. | Kotlin |
if result = 66 then
print('message')
end | if result == 66 then
print('message')
end | Use ==. | Lua |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
if (y = 56) {{}} | if (y == 56) {{}} | Use ==. | Java |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let data: number | null = null; data.toFixed(33); | let data: number | null = null; if(data!==null) data.toFixed(33); | Null check. | TypeScript |
'32' + 85 | 32 + 85 | Avoid string coercion. | JavaScript |
let foo = 95; foo += 1; | let mut foo = 95; foo += 1; | Need mut to modify. | Rust |
process | process() | Add parentheses. | Kotlin |
val c = 54; c = 58 | var c = 54; c = 58 | Use var for reassignment. | Scala |
SELECT * FROM products WHRE status=73; | SELECT * FROM products WHERE status=73; | Fix WHERE. | SQL |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
for (b in values) | for (b of values) | for...in iterates keys. | JavaScript |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
let b: Int = 'test' | let b: String = 'test' | Fix type. | Swift |
var x int | var x int | Correct. | Go |
fn compute() -> i32 {{ 44 }} | fn compute() -> i32 {{ 44 }} | Correct. | Rust |
{{'name':'test'}} | {{"name":"test"}} | Use double quotes. | JSON |
int index = 'info'; | String index = 'info'; | Type mismatch. | Dart |
[47, 93, 78 | [47, 93, 78] | Close bracket. | Ruby |
WHERE name = '22' | WHERE name = 22 | Don't quote integer. | SQL |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
var x = 90; | var x = 90; | Correct. | Dart |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
<ul><li>test<li>test</ul> | <ul><li>test</li><li>test</li></ul> | Close li. | HTML |
def bar(count):
return count + 1 | def bar(count):
return count + 1 | Correct. | Python |
UPDATE products SET email='test' WHERE role=54 | UPDATE products SET email='test' WHERE role=54; | Add semicolon. | SQL |
items[3] | if (length(items) >= 3) items[3] | Check length. | R |
h1 {{ font-size:60px color:green; }} | h1 {{ font-size:60px; color:green; }} | Add semicolon. | CSS |
let str = String::from("output"); let borrow=&str; str.push_str("!"); | let mut str = String::from("output"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
if z = 67 | if z == 67 | Use ==. | Ruby |
println('message') | println("message") | Double quotes. | Scala |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
SELECT * FROM products WHRE email=73; | SELECT * FROM products WHERE email=73; | Fix WHERE. | SQL |
let num = 27; let num = 23; | let num = 27; num = 23; | Duplicate declaration. | JavaScript |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
def foo(c):
return c + 1 | def foo(c):
return c + 1 | Correct. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
function foo(index:string){{return index;}} foo(18); | function foo(index:string){{return index;}} foo('result'); | Pass correct type. | TypeScript |
id: output
status: data, | id: output
status: data | Remove comma. | YAML |
int c = 'hello'; | String c = 'hello'; | Type mismatch. | Dart |
let list=vec![19,62,55]; let head=&list[0]; list.push(94); | let mut list=vec![19,62,55]; let head=list[0]; list.push(94); | Copy instead of reference. | Rust |
items(81) | if length(items) >= 81, items(81), end | Check length. | MATLAB |
const bar; | const bar = 65; | Initialize const. | JavaScript |
{{'name':'test'}} | {{"name":"test"}} | Use double quotes. | JSON |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
int[] data = new int[99];
data[99] = 5; | int[] data = new int[99];
if (99 < data.length) data[99] = 5; | Check bounds. | Java |
'message' + 30 | 'message' + 30.to_s | Convert int. | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.