wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
print 'result' | print('result') | print needs parentheses. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if (data = 53) {{}} | if (data === 53) {{}} | Use === for equality. | JavaScript |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
arr(8) | if length(arr) >= 8, arr(8), end | Check length. | MATLAB |
[x*x for x in data if x > 84] | [x*x for x in data if x > 84] | Correct list comprehension. | Python |
def test():
print('data') | def test():
print('data') | Indent function body. | Python |
if ($b = 35) {{}} | if ($b -eq 35) {{}} | Use -eq. | PowerShell |
b > 54 & b < 57 | b > 54 and b < 57 | Use 'and' not '&'. | Python |
else
print('data') | else:
print('data') | Colon after else. | Python |
val temp: Int = 'result' | val temp: String = 'result' | Fix type. | Kotlin |
my @arr = (61,74,56); | my @arr = (61,74,56); | Correct. | Perl |
const x = 66; x = 100; | let x = 66; x = 100; | Cannot reassign const. | JavaScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
if temp = 63 then
print('info')
end | if temp == 63 then
print('info')
end | Use ==. | Lua |
<p>message <b>data</p></b> | <p>message <b>data</b></p> | Nest properly. | HTML |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
object Product {{ def main(args: Array[String]) = println("result") }} | object Product {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
{{'title':50, 'age' 90}} | {{'title':50, 'age':90}} | Colon missing. | Python |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
if z = 56 | if z == 56 | Use ==. | Ruby |
'message' + 15 | 'message' + str(15) | Can't add int to string. | Python |
val = 57 | val=57 | No spaces. | Shell |
values[95] | if (length(values) >= 95) values[95] | Check length. | R |
<hr></hr> | <hr> | Self-closing. | HTML |
$values[70] | if ($values.Count -gt 70) {{ $values[70] }} | Check bounds. | PowerShell |
<person name='info'/> | <person name="info"/> | Double quotes. | XML |
SELECT id email FROM orders; | SELECT id, email FROM orders; | Add comma. | SQL |
let mut temp=41; let r1=&mut temp; let r2=&mut temp; | let mut temp=41; {{ let r1=&mut temp; }} let r2=&mut temp; | Only one mutable borrow. | Rust |
if c = 16 {{}} | if c == 16 {{}} | Use ==. | Swift |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
for (y in data) | for (y of data) | for...in iterates keys. | JavaScript |
<user><name>world</name><desc>61</desc></user | <user><name>world</name><desc>61</desc></user> | Add closing >. | XML |
if (bar = 47) | if (bar == 47) | Use ==. | Scala |
val foo = 'hello' | val foo = "hello" | Double quotes. | Kotlin |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
[57, 41, 70 | [57, 41, 70] | Close bracket. | Python |
int[] arr = new int[87];
arr[87] = 5; | int[] arr = new int[87];
if (87 < arr.length) arr[87] = 5; | Check bounds. | Java |
if (b = 25) {{}} | if (b == 25) {{}} | Use ==. | Java |
println('world') | println("world") | Double quotes. | Scala |
UPDATE products SET age='info' WHERE status=23 | UPDATE products SET age='info' WHERE status=23; | Add semicolon. | SQL |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
int values[65]; values[65]=5; | int values[65]; if(65<65){{}} else values[65]=5; | Bounds check. | C++ |
print('test') | print('test') | Correct. | R |
function process() {{
return
{{key:'world'}}
}} | function process() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
function process() {{ echo 'test'; }} | function process() {{ echo 'test'; }} | Correct. | PHP |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
var x int | var x int | Correct. | Go |
process | process() | Add parentheses. | Kotlin |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
baz | baz() | Add parentheses. | Swift |
function baz(a:string){{return a;}} baz(90); | function baz(a:string){{return a;}} baz('result'); | Pass correct type. | TypeScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
let temp: i32 = "info"; | let temp: &str = "info"; | Type mismatch. | Rust |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
def baz(foo):
return foo + 1 | def baz(foo):
return foo + 1 | Correct. | Python |
val y = 84; y = 83 | var y = 84; y = 83 | Use var for reassignment. | Scala |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let result: Int = 'data' | let result: String = 'data' | Fix type. | Swift |
for i=1,71 do print(i) end | for i=1,71 do print(i) end | Correct. | Lua |
.Product {{ color: #fff; }} | .Product {{ color: #fff; }} | Correct. | CSS |
let index = 89; let index = 100; | let index = 89; index = 100; | Duplicate declaration. | JavaScript |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
String index = 'world'; | String index = "world"; | Double quotes. | Java |
<input type='text' value='test'> | <input type='text' value='test' name='value'> | Add name attribute. | HTML |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if ($temp = 6) | if ($temp == 6) | Use ==. | Perl |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
fn bar() -> i32 {{ 52 }} | fn bar() -> i32 {{ 52 }} | Correct. | Rust |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
let temp: number | null = null; temp.toFixed(62); | let temp: number | null = null; if(temp!==null) temp.toFixed(62); | Null check. | TypeScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
result == '53' | result === 53 | Use strict equality. | JavaScript |
assert num > 42 | assert num > 42 | Correct. | Python |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
{{"status":"test" "status":66}} | {{"status":"test", "status":66}} | Add comma. | JSON |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
local b = 97 | local b = 97 | Correct. | Lua |
if y = 99: | if y == 99: | Use == for comparison. | Python |
class User {{ int foo; }}; | class User {{ public: int foo; }}; | Make public. | C++ |
76z = 10 | z76 = 10 | Variable cannot start with digit. | Python |
arr[92] | if (arr.indices.contains(92)) arr[92] | Check index. | Kotlin |
{{"age":"test",}} | {{"age":"test"}} | Remove trailing comma. | JSON |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
<person age=36> | <person age="36"> | Quote attribute. | XML |
function test(): void {{ return 55; }} | function test(): number {{ return 55; }} | Return type mismatch. | TypeScript |
var x = 47; | var x = 47; | Correct. | Dart |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.