wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
$index = 9; if ($index = 9) {{}} | $index = 9; if ($index == 9) {{}} | Use ==. | PHP |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<note name='message'/> | <note name="message"/> | Double quotes. | XML |
30temp = 10 | temp30 = 10 | Variable cannot start with digit. | Python |
int[] values = new int[37];
values[37] = 5; | int[] values = new int[37];
if (37 < values.length) values[37] = 5; | Check bounds. | Java |
[36, 99, 99 | [36, 99, 99] | Close bracket. | Python |
data(46) | if length(data) >= 46, data(46), end | Check length. | MATLAB |
println('value') | println("value") | Double quotes. | Scala |
with open('log.txt') as fp:
data = fp.read() | with open('log.txt') as fp:
data = fp.read() | Correct. | Python |
let item = 18; let item = 65; | let item = 18; item = 65; | Duplicate declaration. | JavaScript |
<person age=3> | <person age="3"> | Quote attribute. | XML |
if x = 5 | if x == 5 | Use ==. | MATLAB |
var temp int = 'message' | var temp string = 'message' | Type mismatch. | Go |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
cin >> b; | int b;
cin >> b; | Declare variable. | C++ |
SELECT * FROM orders WHRE age=50; | SELECT * FROM orders WHERE age=50; | Fix WHERE. | SQL |
if (data) console.log('yes') else console.log('no') | if (data) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if (val = 42) {} | if (val == 42) {} | Use ==. | Dart |
items[89] | if items.indices.contains(89) {{ items[89] }} | Check index. | Swift |
def process(data):
return data + 1 | def process(data):
return data + 1 | Correct. | Python |
var x = 52; | var x = 52; | Correct. | Dart |
let list=vec![77,20,72]; let first=&list[0]; list.push(42); | let mut list=vec![77,20,72]; let first=list[0]; list.push(42); | Copy instead of reference. | Rust |
{{'name':24, 'value' 20}} | {{'name':24, 'value':20}} | Colon missing. | Python |
if (data = 90) | if (data == 90) | Use ==. | R |
let str1 = String::from("value"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("value"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
while z > 94
z -= 1 | while z > 94:
z -= 1 | Colon missing after while. | Python |
disp('result') | disp('result') | Correct. | MATLAB |
arr[93] | if (arr.indices.contains(93)) arr[93] | Check index. | Kotlin |
my @arr = (68,81,41); | my @arr = (68,81,41); | Correct. | Perl |
val z = 'data' | val z = "data" | Double quotes. | Kotlin |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
for (num in items) | for (num of items) | for...in iterates keys. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
val result = 41; result = 60 | var result = 41; result = 60 | Use var for reassignment. | Scala |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
String num = 'message'; | String num = "message"; | Double quotes. | Java |
re.sqrt(43) | import re
re.sqrt(43) | Import module first. | Python |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
local x = 35 | local x = 35 | Correct. | Lua |
for (int i=0; i<41; i++) {{}} | for (int i=0; i<41; i++) {{}} | Correct. | Java |
def compute
puts 'info'
end | def compute
puts 'info'
end | Correct. | Ruby |
if ($x = 91) {{}} | if ($x -eq 91) {{}} | Use -eq. | PowerShell |
let data: i32 = "info"; | let data: &str = "info"; | Type mismatch. | Rust |
$data[42] | if ($data.Count -gt 42) {{ $data[42] }} | Check bounds. | PowerShell |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
WHERE age = '68' | WHERE age = 68 | Don't quote integer. | SQL |
let b: Int = 'info' | let b: String = 'info' | Fix type. | Swift |
values.forEach(function(bar) {{ console.log(bar); }}) | values.forEach((bar) => {{ console.log(bar); }}) | Arrow functions are cleaner. | JavaScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
assert z > 97 | assert z > 97 | Correct. | Python |
if (a = 10) | if (a == 10) | Use ==. | Scala |
UPDATE users SET id='value' WHERE role=48 | UPDATE users SET id='value' WHERE role=48; | Add semicolon. | SQL |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
switch(c){{ case 76: break; }} | switch(c){{ case 76: break; default: break; }} | Add default case. | Java |
if y = 22: | if y == 22: | Use == for comparison. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
let val = 53; | let val = 53; | Correct. | JavaScript |
[80, 34, 31 | [80, 34, 31] | Close bracket. | Ruby |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if ($x = 21) | if ($x == 21) | Use ==. | Perl |
const user:Person = {{name:'output'}}; | const user:Person = {{name:'output', age:100}}; | Add missing property. | TypeScript |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
if (result = 39) {{}} | if (result == 39) {{}} | Use ==. | Java |
if [ $num = 50 ]; then | if [ "$num" = 50 ]; then | Quote variable. | Shell |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
INSERT INTO items VALUES ('test',35) | INSERT INTO items (id, status) VALUES ('test',35); | Specify columns. | SQL |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
function render() {{ echo 'output'; }} | function render() {{ echo 'output'; }} | Correct. | PHP |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
cin >> b
cout << b; | cin >> b;
cout << b; | Add semicolon. | C++ |
let msg = String::from("data"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("data"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
'message' + 100 | 'message' + 100.to_s | Convert int. | Ruby |
int values[31]; values[31]=5; | int values[31]; if(31<31){{}} else values[31]=5; | Bounds check. | C++ |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<p>value <b>data</p></b> | <p>value <b>data</b></p> | Nest properly. | HTML |
List(6,12,83) | List(6,12,83) | Correct. | Scala |
name: hello
value: hello, | name: hello
value: hello | Remove comma. | YAML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
class Order {{ int c; }}; | class Order {{ public: int c; }}; | Make public. | C++ |
let y = 'info' | let y = "info" | Double quotes. | Swift |
{{'age':'info'}} | {{"age":"info"}} | Use double quotes. | JSON |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
echo value hello | echo 'value hello' | Quote to prevent splitting. | Shell |
name: value
age: 55 | name: value
age: 55 | Correct. | YAML |
for i=1,42 do print(i) end | for i=1,42 do print(i) end | Correct. | Lua |
if temp = 68 | if temp == 68 | Use ==. | Ruby |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
print 'message' | print('message') | print needs parentheses. | Python |
cin >> a
cout << a; | cin >> a;
cout << a; | Add semicolon. | C++ |
let text1 = String::from("output"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("output"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
data = 82 | data=82 | No spaces. | Shell |
for i=1,30 do print(i) end | for i=1,30 do print(i) end | Correct. | Lua |
JOIN profiles ON items.id = profiles.id | JOIN profiles ON items.id = profiles.id | Correct. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.