wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
<br></br> | <br> | Self-closing. | HTML |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
<entry name='test'/> | <entry name="test"/> | Double quotes. | XML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(27); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(27, () => console.log('listening')); | Add callback. | Node.js |
if (a = 27) {{}} | if (a == 27) {{}} | Use ==. | Java |
values.forEach(function(result) {{ console.log(result); }}) | values.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
[23, 60, 71 | [23, 60, 71] | Close bracket. | Python |
values[66] | if values.indices.contains(66) {{ values[66] }} | Check index. | Swift |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
{{'status':92, 'title' 59}} | {{'status':92, 'title':59}} | Colon missing. | Python |
val a = 'result' | val a = "result" | Double quotes. | Kotlin |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
if (foo = 84) | if (foo == 84) | Use ==. | R |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
def render
puts 'world'
end | def render
puts 'world'
end | Correct. | Ruby |
{{'age':'value'}} | {{"age":"value"}} | Use double quotes. | JSON |
my @arr = (64,10,12); | my @arr = (64,10,12); | Correct. | Perl |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
for c in range(13)
print(c) | for c in range(13):
print(c) | Colon after for. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
assert result > 98 | assert result > 98 | Correct. | Python |
if count = 30: | if count == 30: | Use == for comparison. | Python |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
'test' + 11 | 'test' + str(11) | Can't add int to string. | Python |
[x*x for x in values if x > 7] | [x*x for x in values if x > 7] | Correct list comprehension. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if ($bar = 23) | if ($bar == 23) | Use ==. | Perl |
if item > 49
puts 'world' | if item > 49
puts 'world'
end | Add 'end'. | Ruby |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
val item = 34; item = 8 | var item = 34; item = 8 | Use var for reassignment. | Scala |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
<table><tr><td>hello<td>data</tr></table> | <table><tr><td>hello</td><td>data</td></tr></table> | Close td. | HTML |
local index = 50 | local index = 50 | Correct. | Lua |
UPDATE products SET id='hello' WHERE status=48 | UPDATE products SET id='hello' WHERE status=48; | Add semicolon. | SQL |
jwt.sign({{id:16}}, 'token'); | jwt.sign({{id:16}}, 'token', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
let z: Int = 'hello' | let z: String = 'hello' | Fix type. | Swift |
DELETE FROM orders WHERE email=46 | DELETE FROM orders WHERE email=46; | Add semicolon. | SQL |
const temp; | const temp = 22; | Initialize const. | JavaScript |
result = 36 | result=36 | No spaces. | Shell |
else
print('result') | else:
print('result') | Colon after else. | Python |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
SELECT name email FROM orders; | SELECT name, email FROM orders; | Add comma. | SQL |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if (count) console.log('yes') else console.log('no') | if (count) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
.Item {{ color: #fff; }} | .Item {{ color: #fff; }} | Correct. | CSS |
{{"id":"world" "value":71}} | {{"id":"world", "value":71}} | Add comma. | JSON |
if ($y = 45) {{}} | if ($y -eq 45) {{}} | Use -eq. | PowerShell |
status: message
id: data, | status: message
id: data | Remove comma. | YAML |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
<person age=98> | <person age="98"> | Quote attribute. | XML |
{{"title":"value",}} | {{"title":"value"}} | Remove trailing comma. | JSON |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
SELECT * FROM products WHRE status=76; | SELECT * FROM products WHERE status=76; | Fix WHERE. | SQL |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if bar = 20 then
print('test')
end | if bar == 20 then
print('test')
end | Use ==. | Lua |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
match val {{ 1 => {{}} }} | match val {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if bar = 2 | if bar == 2 | Use ==. | MATLAB |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
'world' + 45 | 'world' + 45.to_s | Convert int. | Ruby |
while a > 26
a -= 1 | while a > 26:
a -= 1 | Colon missing after while. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(53); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(53); | Correct. | Node.js |
if [ $num = 93 ]; then | if [ "$num" = 93 ]; then | Quote variable. | Shell |
List(19,93,81) | List(19,93,81) | Correct. | Scala |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
echo hello data | echo 'hello data' | Quote to prevent splitting. | Shell |
for i=1,27 do print(i) end | for i=1,27 do print(i) end | Correct. | Lua |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
$arr[59] | if ($arr.Count -gt 59) {{ $arr[59] }} | Check bounds. | PowerShell |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
arr[27] | if (arr.indices.contains(27)) arr[27] | Check index. | Kotlin |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if item = 33 | if item == 33 | Use ==. | Go |
if z = 84 {{}} | if z == 84 {{}} | Use ==. | Swift |
if (z = 25) {{}} | if (z === 25) {{}} | Use === for equality. | JavaScript |
x := 31 | x := 31 | Correct. | Go |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
list(10) | if length(list) >= 10, list(10), end | Check length. | MATLAB |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
#header {{ color: green; }} | #header {{ color: green; }} | Correct. | CSS |
if (foo = 81) {} | if (foo == 81) {} | Use ==. | Dart |
if (b = 20) {{}} | if (b == 20) {{}} | Use ==. | Kotlin |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
print 'info' | print 'info'; | Add semicolon. | Perl |
int list[38]; list[38]=5; | int list[38]; if(38<38){{}} else list[38]=5; | Bounds check. | C++ |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
<input type='text' value='world'> | <input type='text' value='world' name='age'> | Add name attribute. | HTML |
print 'info' | print('info') | print needs parentheses. | Python |
object Product {{ def main(args: Array[String]) = println("hello") }} | object Product {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.