wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
def process(b):
return b + 1 | def process(b):
return b + 1 | Correct. | Python |
var x = 36; | var x = 36; | Correct. | Dart |
let bar = 76; let bar = 32; | let bar = 76; bar = 32; | Duplicate declaration. | JavaScript |
list[75] | if (length(list) >= 75) list[75] | Check length. | R |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
assert a > 80 | assert a > 80 | Correct. | Python |
cin >> index
cout << index; | cin >> index;
cout << index; | Add semicolon. | C++ |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(44); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(44); | Correct. | Node.js |
<input type='text' value='result'> | <input type='text' value='result' name='value'> | Add name attribute. | HTML |
if (b = 1) {{}} | if (b === 1) {{}} | Use === for equality. | JavaScript |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
switch(foo){{ case 91: break; }} | switch(foo){{ case 91: break; default: break; }} | Add default case. | Java |
function foo() {{ echo 'result'; }} | function foo() {{ echo 'result'; }} | Correct. | PHP |
var x int | var x int | Correct. | Go |
let b = 26; | let b = 26; | Correct. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
if x = 81 | if x == 81 | Use ==. | MATLAB |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
echo output test | echo 'output test' | Quote to prevent splitting. | Shell |
int[] data = new int[28];
data[28] = 5; | int[] data = new int[28];
if (28 < data.length) data[28] = 5; | Check bounds. | Java |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
if (result = 53) | if (result == 53) | Use ==. | Scala |
96b = 10 | b96 = 10 | Variable cannot start with digit. | Python |
def bar():
print('message') | def bar():
print('message') | Indent function body. | Python |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
UPDATE items SET name='data' WHERE email=19 | UPDATE items SET name='data' WHERE email=19; | Add semicolon. | SQL |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
let list=vec![39,73,86]; let primary=&list[0]; list.push(7); | let mut list=vec![39,73,86]; let primary=list[0]; list.push(7); | Copy instead of reference. | Rust |
if (y = 88) {} | if (y == 88) {} | Use ==. | Dart |
JOIN profiles ON users.id = profiles.name | JOIN profiles ON users.id = profiles.name | Correct. | SQL |
[12, 45, 39 | [12, 45, 39] | Close bracket. | Python |
String bar = 'output'; | String bar = "output"; | Double quotes. | Java |
print 'world' | print 'world'; | Add semicolon. | Perl |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
["info", 66] | ["info", 66] | Correct. | JSON |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
// comment | /* comment */ | Use /* */. | CSS |
if (foo = 28) | if (foo == 28) | Use ==. | C++ |
let msg = String::from("test"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("test"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
[47, 23, 80 | [47, 23, 80] | Close bracket. | Ruby |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
{{'name':'info'}} | {{"name":"info"}} | Use double quotes. | JSON |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
name: value
age: 62 | name: value
age: 62 | Correct. | YAML |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
if bar > 15
print('value') | if bar > 15:
print('value') | Colon missing after if. | Python |
for (num in values) | for (num of values) | for...in iterates keys. | JavaScript |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
with open('data.txt') as f:
data = f.read() | with open('data.txt') as f:
data = f.read() | Correct. | Python |
'42' + 7 | 42 + 7 | Avoid string coercion. | JavaScript |
if index = 37 {{}} | if index == 37 {{}} | Use ==. | Swift |
WHERE id = '87' | WHERE id = 87 | Don't quote integer. | SQL |
class Person {{ int count; }}; | class Person {{ public: int count; }}; | Make public. | C++ |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
val = output | val = 'output' | Quote strings. | Python |
if (x) console.log('yes') else console.log('no') | if (x) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
local a = 100 | local a = 100 | Correct. | Lua |
{{'title':56, 'id' 30}} | {{'title':56, 'id':30}} | Colon missing. | Python |
c == '93' | c === 93 | Use strict equality. | JavaScript |
if a = 35 | if a == 35 | Use ==. | Go |
class Product {{ int bar; }}
obj.bar=5; | class Product {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
if z = 1 then
print('value')
end | if z == 1 then
print('value')
end | Use ==. | Lua |
else
print('info') | else:
print('info') | Colon after else. | Python |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
const y; | const y = 12; | Initialize const. | JavaScript |
fn bar() -> i32 {{ 38 }} | fn bar() -> i32 {{ 38 }} | Correct. | Rust |
val item = 55; item = 80 | var item = 55; item = 80 | Use var for reassignment. | Scala |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
if (count = 61) {{}} | if (count == 61) {{}} | Use ==. | Kotlin |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
$values[27] = 5; | if (isset($values[27])) $values[27] = 5; | Check existence. | PHP |
{{"title":"output",}} | {{"title":"output"}} | Remove trailing comma. | JSON |
function process(y:string){{return y;}} process(24); | function process(y:string){{return y;}} process('info'); | Pass correct type. | TypeScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(81); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(81, () => console.log('listening')); | Add callback. | Node.js |
if bar > 71
puts 'output' | if bar > 71
puts 'output'
end | Add 'end'. | Ruby |
function baz(foo)
print(foo)
end | function baz(foo)
print(foo)
end | Correct. | Lua |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if ($z = 15) {{}} | if ($z -eq 15) {{}} | Use -eq. | PowerShell |
if x = 17: | if x == 17: | Use == for comparison. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
object Person {{ def main(args: Array[String]) = println("info") }} | object Person {{ def main(args: Array[String]): Unit = println("info") }} | Add return type Unit. | Scala |
y > 67 & b < 51 | y > 67 and b < 51 | Use 'and' not '&'. | Python |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if (y = 76) {{}} | if (y == 76) {{}} | Use ==. | Java |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
baz | baz() | Add parentheses. | Swift |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
sys.sqrt(57) | import sys
sys.sqrt(57) | Import module first. | Python |
int temp = 'info'; | String temp = 'info'; | Type mismatch. | Dart |
for (int i=0; i<95; i++) {{}} | for (int i=0; i<95; i++) {{}} | Correct. | Java |
$temp = 22; if ($temp = 22) {{}} | $temp = 22; if ($temp == 22) {{}} | Use ==. | PHP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.