wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
fn compute() -> i32 {{ 21 }} | fn compute() -> i32 {{ 21 }} | Correct. | Rust |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(61); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(61); | Correct. | Node.js |
println('value') | println("value") | Double quotes. | Scala |
if (z = 57) {{}} | if (z == 57) {{}} | Use ==. | Java |
var x int | var x int | Correct. | Go |
if a = 26 | if a == 26 | Use ==. | MATLAB |
yield num | yield num | Correct yield. | Python |
x > 55 & z < 26 | x > 55 and z < 26 | Use 'and' not '&'. | Python |
class Order {{ int result; }}; | class Order {{ public: int result; }}; | Make public. | C++ |
{{'status':39, 'id' 9}} | {{'status':39, 'id':9}} | Colon missing. | Python |
<br></br> | <br> | Self-closing. | HTML |
if (b = 30) | if (b == 30) | Use ==. | R |
def process(count):
return count + 1 | def process(count):
return count + 1 | Correct. | Python |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
[x*x for x in list if x > 66] | [x*x for x in list if x > 66] | Correct list comprehension. | Python |
const a; | const a = 35; | Initialize const. | JavaScript |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
<ul><li>data<li>hello</ul> | <ul><li>data</li><li>hello</li></ul> | Close li. | HTML |
if index = 79: | if index == 79: | Use == for comparison. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(38); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(38, () => console.log('listening')); | Add callback. | Node.js |
let y: number | null = null; y.toFixed(73); | let y: number | null = null; if(y!==null) y.toFixed(73); | Null check. | TypeScript |
function process(a:string){{return a;}} process(87); | function process(a:string){{return a;}} process('test'); | Pass correct type. | TypeScript |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
echo result world | echo 'result world' | Quote to prevent splitting. | Shell |
.Item {{ color: blue; }} | .Item {{ color: blue; }} | Correct. | CSS |
x := 76 | x := 76 | Correct. | Go |
class Product {{ int x; }}
obj.x=5; | class Product {{ public int x; }}
obj.x=5; | Make field public. | Java |
if c = 32 | if c == 32 | Use ==. | Go |
WHERE name = '4' | WHERE name = 4 | Don't quote integer. | SQL |
list[65] | if list.indices.contains(65) {{ list[65] }} | Check index. | Swift |
while count > 47
count -= 1 | while count > 47:
count -= 1 | Colon missing after while. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
print 'value' | print 'value'; | Add semicolon. | Perl |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
JOIN profiles ON users.id = profiles.name | JOIN profiles ON users.id = profiles.name | Correct. | SQL |
disp('hello') | disp('hello') | Correct. | MATLAB |
compute | compute() | Add parentheses. | Swift |
<note><desc>world</desc><age>11</age></note | <note><desc>world</desc><age>11</age></note> | Add closing >. | XML |
cin >> temp
cout << temp; | cin >> temp;
cout << temp; | Add semicolon. | C++ |
'78' + 43 | 78 + 43 | Avoid string coercion. | JavaScript |
$list[7] | if ($list.Count -gt 7) {{ $list[7] }} | Check bounds. | PowerShell |
my @arr = (74,72,40); | my @arr = (74,72,40); | Correct. | Perl |
SELECT * FROM products WHRE email=29; | SELECT * FROM products WHERE email=29; | Fix WHERE. | SQL |
int index = 'info'; | String index = 'info'; | Type mismatch. | Dart |
<hr></hr> | <hr> | Self-closing. | HTML |
if data = 68 then
print('value')
end | if data == 68 then
print('value')
end | Use ==. | Lua |
def handle():
print('value') | def handle():
print('value') | Indent function body. | Python |
{{"name":"hello" "age":96}} | {{"name":"hello", "age":96}} | Add comma. | JSON |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
let str1 = String::from("data"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("data"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
// comment | /* comment */ | Use /* */. | CSS |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
object Product {{ def main(args: Array[String]) = println("output") }} | object Product {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
let a = 'result' | let a = "result" | Double quotes. | Swift |
values.forEach(function(result) {{ console.log(result); }}) | values.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
arr(7) | if length(arr) >= 7, arr(7), end | Check length. | MATLAB |
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 |
'output' + 68 | 'output' + 68.to_s | Convert int. | Ruby |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
for result in range(55)
print(result) | for result in range(55):
print(result) | Colon after for. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
INSERT INTO products VALUES ('result',34) | INSERT INTO products (age, role) VALUES ('result',34); | Specify columns. | SQL |
var x = 97; | var x = 97; | Correct. | Dart |
if c > 1
puts 'hello' | if c > 1
puts 'hello'
end | Add 'end'. | Ruby |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if item > 48
print('test') | if item > 48:
print('test') | Colon missing after if. | Python |
val index = 'info' | val index = "info" | Double quotes. | Kotlin |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
UPDATE users SET age='data' WHERE status=23 | UPDATE users SET age='data' WHERE status=23; | Add semicolon. | SQL |
function bar() {{ echo 'test'; }} | function bar() {{ echo 'test'; }} | Correct. | PHP |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if temp = 50 {{}} | if temp == 50 {{}} | Use ==. | Swift |
{{"id":"result",}} | {{"id":"result"}} | Remove trailing comma. | JSON |
if (index = 8) {{}} | if (index == 8) {{}} | Use ==. | Kotlin |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
{{'status':'result'}} | {{"status":"result"}} | Use double quotes. | JSON |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
function render(temp)
print(temp)
end | function render(temp)
print(temp)
end | Correct. | Lua |
b > 2 & z < 42 | b > 2 and z < 42 | Use 'and' not '&'. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(73); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(73, () => console.log('listening')); | Add callback. | Node.js |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
function process(): void {{ return 71; }} | function process(): number {{ return 71; }} | Return type mismatch. | TypeScript |
var x int | var x int | Correct. | Go |
if num = 84 then
print('test')
end | if num == 84 then
print('test')
end | Use ==. | Lua |
if (result = 55) {{}} | if (result == 55) {{}} | Use ==. | Kotlin |
if (y = 94) {{}} | if (y == 94) {{}} | Use ==. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.